Algorithms and Data Structures Exercise I

Similar documents
First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

PA3 Design Specification

Name CPTR246 Spring '17 (100 total points) Exam 3

STACKS AND QUEUES. Problem Solving with Computers-II

12 Abstract Data Types

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

The Stack and Queue Types

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

Formal Languages and Automata Theory, SS Project (due Week 14)

Stacks, Queues and Hierarchical Collections

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

CS 206 Introduction to Computer Science II

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

3137 Data Structures and Algorithms in C++

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

TREES. Trees - Introduction

Data Structure Advanced

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Stacks, Queues and Hierarchical Collections. 2501ICT Logan

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents

Stacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

Tree. Virendra Singh Indian Institute of Science Bangalore Lecture 11. Courtesy: Prof. Sartaj Sahni. Sep 3,2010

The Bucharest University of Economic Studies. Data Structures. ADTs-Abstract Data Types Stacks and Queues

Table of Contents. Chapter 1: Introduction to Data Structures... 1

March 20/2003 Jayakanth Srinivasan,

Binary Trees, Binary Search Trees

syntax tree - * * * * * *

CS 206 Introduction to Computer Science II

ASTS, GRAMMARS, PARSING, TREE TRAVERSALS. Lecture 14 CS2110 Fall 2018

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS. Regrades 10/6/15. Prelim 1. Prelim 1. Expression trees. Pointers to material

Data Structures Question Bank Multiple Choice

ECE250: Algorithms and Data Structures Midterm Review

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50

Lecture 4 Stack and Queue

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

Chapter 4 Trees. Theorem A graph G has a spanning tree if and only if G is connected.

Data Structures. Trees. By Dr. Mohammad Ali H. Eljinini. M.A. Eljinini, PhD

Computer Science 1 Study Union Practice Problems. What are the arguments to malloc? calloc? realloc? What do they do?

CS301 - Data Structures Glossary By

EE 368. Week 6 (Notes)

Postfix (and prefix) notation

Associate Professor Dr. Raed Ibraheem Hamed

Topic 14. The BinaryTree ADT

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

CS61BL. Lecture 3: Asymptotic Analysis Trees & Tree Traversals Stacks and Queues Binary Search Trees (and other trees)

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Trees! Ellen Walker! CPSC 201 Data Structures! Hiram College!

Course Review. Cpt S 223 Fall 2009

Department of Computer Science and Technology

DATA STRUCTURE UNIT I

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

Draw a diagram of an empty circular queue and describe it to the reader.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

ADTS, GRAMMARS, PARSING, TREE TRAVERSALS


Stack Abstract Data Type

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Algorithm Class. C C++ DS JAVA DATA STRUCTURES TRAINING INSTITUTE KPHB HYDERABAD. Mobile:

Stacks. Revised based on textbook author s notes.

Separate Compilation and Namespaces Week Fall. Computer Programming for Engineers

infix expressions (review)

F453 Module 7: Programming Techniques. 7.2: Methods for defining syntax

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

How to Win Coding Competitions: Secrets of Champions. Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue.

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

Stacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved

An Introduction to Trees

Data Structures, Algorithms & Data Science Platforms

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

CMSC Introduction to Algorithms Spring 2012 Lecture 7

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

CS61B Lecture #20: Trees. Last modified: Wed Oct 12 12:49: CS61B: Lecture #20 1

Recursive Data Structures and Grammars

Cpt S 122 Data Structures. Course Review FINAL. Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University

CSC148 Week 6. Larry Zhang

Computer Science 210 Data Structures Siena College Fall Topic Notes: Trees

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

ECE Spring 2018 Problem Set #0 Due: 1/30/18

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

CSE 332: Data Structures. Spring 2016 Richard Anderson Lecture 1

Course Review for Finals. Cpt S 223 Fall 2008

CSI33 Data Structures

tree nonlinear Examples

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

Introduction to Computers and Programming. Concept Question

COP 3502 Section 2 Exam #2 Version A Spring /23/2017

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

Tree. A path is a connected sequence of edges. A tree topology is acyclic there is no loop.

CS2383 Programming Assignment 3

Tree Applications. Processing sentences (computer programs or natural languages) Searchable data structures

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

COMP 250 Fall binary trees Oct. 27, 2017

Chapter 20: Binary Trees

Stacks, Queues & Trees. The Stack Interface. The Stack Interface. Harald Gall, Prof. Dr.

#06 More Structures LIFO FIFO. Contents. Queue vs. Stack 3. Stack Operations. Pop. Push. Stack Queue Hash table

Transcription:

Algorithms and Data Structures Exercise I Banafsheh Azari http://www.uni-weimar.de/de/medien/professuren/grafischedatenverarbeitung/ Bauhaus-University Weimar - CogVis/MMC May 3, 2017 c 2017, Algorithms and Data Structures Exercise I Exercise I 1/23

Exercise Wednesday,11:00, SR014, B11 Even weeks First Exercise : 03.05.2017 c 2017, Algorithms and Data Structures Exercise I Exercise I 2/23

Exercise 5 Assignments max 6 point for each assigment 30% exercise and 70% final exam c 2017, Algorithms and Data Structures Exercise I Exercise I 3/23

Exercise Conditions C/C++ or Java Compilable source code (gcc or javac) No IDEs Readable source code Self-contained submission c 2017, Algorithms and Data Structures Exercise I Exercise I 4/23

Exercise Comments Sufficient comments (rule of thumb: another Developers can get program logic alone by reading the comments) In each! Data: Name, matriculation number, SS2017 c 2017, Algorithms and Data Structures Exercise I Exercise I 5/23

Exercise Tasks: www.uni-weimar.de/de/medien/professuren/grafischedatenverarbeitung/ Submission: per E-Mail as NameLastname E... c 2017, Algorithms and Data Structures Exercise I Exercise I 6/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Data Structures Array Linked Lists Stacks LIFO Push pop Queues FIFO enqueue dequeue Trees Graphs c 2017, Algorithms and Data Structures Exercise I Exercise I 7/23

Polynomial g x =mx +nx +ox+p coef expo next Start m 4 n 2 o 1 p 0 c 2017, Algorithms and Data Structures Exercise I Exercise I 8/23

Polynomial Addition f x =ax +bx +cx Start g x =mx +nx +ox+p a 5 b 3 c 1 Start m 4 n 2 o 1 p 0 h x =f x +g x =ax +mx +bx +nx + c+o x+p c 2017, Algorithms and Data Structures Exercise I Exercise I 9/23

Infix and Postfix Expression Infix expression (A * (B + (C / D) ) ) Postfix expression (A (B (C D /) +) *) Prefix expression (* A (+ B (/ C D) ) ) c 2017, Algorithms and Data Structures Exercise I Exercise I 10/23

Converting Example stack original expression 5/7+2*4*3 postfix expression 5 / + * + * + + push / 5 7 pop / push + 5 7 / 5 7 / 2 push * 5 7 / 2 4 pop * push * 5 7 / 2 4 * pop * 5 7 / 2 4 * 3 * pop + 5 7 / 2 4 * 3 * + c 2017, Algorithms and Data Structures Exercise I Exercise I 11/23

Calculation Example stack original expression 2 4 * 9 5 + - 2 4 2 push 2 push 4 pop 4 pop 2 push 2*4 8 5 9 8 14 8-6 push 9 push 5 pop 5 pop 9 push 9+5 pop 14 pop 8 push 8-14 c 2017, Algorithms and Data Structures Exercise I Exercise I 12/23

Trees Terminology A S M E P L Q T c 2017, Algorithms and Data Structures Exercise I Exercise I 13/23

Trees A S M E P L Terminology Node External node: leaf Internal node Edge Path Root Q T c 2017, Algorithms and Data Structures Exercise I Exercise I 14/23

Trees A N=number of nodes M=number of edges M=N-1 S M E P L Q T c 2017, Algorithms and Data Structures Exercise I Exercise I 15/23

Trees Implementing A B C D E F c 2017, Algorithms and Data Structures Exercise I Exercise I 16/23

Trees traversing methods A S M E P L Q T c 2017, Algorithms and Data Structures Exercise I Exercise I 17/23

Tree traversing methods S A M Preorder Inorder Postorder Level-Order E P N L X K Q T c 2017, Algorithms and Data Structures Exercise I Exercise I 18/23

Trees * A + B / C D c 2017, Algorithms and Data Structures Exercise I Exercise I 19/23

Huffman coding ABACCDA 010100010000000111010 21 bit Character D C B A Code 111 000 100 010 00010010101100 14 bit Character D C B A Code 11 10 01 00 0110010101110 13 bit Character D C B A Code 111 10 110 0 c 2017, Algorithms and Data Structures Exercise I Exercise I 20/23

Palindrome & Anagram madam m m a a d d a a m m c 2017, Algorithms and Data Structures Exercise I Exercise I 21/23

Assignment I Write a program that reads an infix expression as input, convert it to postfix expression and calculate the integer result. Return the postfix order and the integer result as output. Assume the infix expression is a string of tokens delimited by spaces. The operator tokens are *, /, +, and -. The operands are assumed to be single-digit integer values. Example: Enter an infix expression: 1 + 2-3 Postfix expression is: 1 2 + 3 - Evaluation of expression is: 0 Use array or linked list to implement the Stack and Queue. Deadline: 17. May 2017 23:59 Mailto: banafsheh.azari@uni-weimar.de Good luck! c 2017, Algorithms and Data Structures Exercise I Exercise I 22/23