Procedural Programming & Fundamentals of Programming
|
|
- Amos Briggs
- 5 years ago
- Views:
Transcription
1 Procedural Programming & Fundamentals of Programming Lecture 4 - Summer Semester 2018 & Joachim Zumbrägel Writing a computer program is only one step in the Program Development Process 2 1
2 What we know so far... (1/3) Computers should help us to solve problems First we need to understand the problem, which requires to get all relevant information Then we create a step-wise solution to it, which at its best is following a problem-solving strategy 3 What we know so far... (2/3) By means of flowcharts (for algorithm) and pseudocode (for program) we document and structure our solution approach A computer executes the program, which we write in a specific programming language 4 2
3 What we know so far... (3/3) Control structures serve to manage the order of instructions, which change data in the main memory of a computer. To organize this data and its respective manipulation, we use data types and data structures. The challenge is to develop a proper abstraction of the system in the real world into a problem model to be solved by the computer. We are responsible for the programs that we write. 5 Struct(ures) 3
4 Records (Structures) A record permits a programmer to handle a group of variables as one variable The fields / members / components of a record can be any built-in or programmer-defined data type A record can have values assigned to and read from it just like the built-in variable types A record can also be passed as an argument to a function and serve as the return value for a function 7 Structures in C A struct is a mechanism for grouping together related data items of different types. Recall: An array groups items of a single type Example: We want to represent an airborne aircraft: We can use a struct to group these data together for each plane. 8 4
5 Defining a Struct We first need to define a new type for the compiler and tell it what our struct looks like. This tells the compiler how big our struct is and how the different data items ( members ) are laid out in memory. But it does not allocate any memory. 9 Declaring and Using a Struct planea altitude flightnum: 409 flighttype planea ; Access: flighttype planeb ; Access: planea. flightnum planeb. flightnum planea. airspeed planeb. airspeed planeb flightnum: 1767 planea. altitude planeb. altitude time planea. time == planeb. time 10 5
6 Declaring and Using a Struct To allocate memory for a struct, we declare a variable plane using our new struct data type struct flight type. Memory is allocated, and we can access individual members of this variable: A struct s members are laid out in the order specified by the definition. 11 Airplane Coordinates Position time x y z 100s x0 y0 z0 200s x1 y0 z1 300s x2 y0 z2 400s x3 y0 z3 500s x4 y0 z4 600s x5 y0 z5 700s x6 y0 z6 800s x7 y0 z7 900s x8 y0 z8 1000s x9 y0 z9 12 6
7 Airplane Coordinates (in km) Position time x y z 100s s s 400s 500s 600s 700s 800s 900s 1000s 13 Airplane time Index Element of Array t 100s 0 t [0] 200s 1 t [1] 300s 2 t [2] 400s 3 t [3] 500s 4 t [4] 600s 5 t [5] 700s 6 t [6] 800s 7 t [7] 900s 8 t [8] 1000s 9 t [9] Cells in Main Memory From the previous lecture: At 100s Define an array of type flighttype: flighttype t[10]; At 200s At 300s At 400s At 500s At 600s User defined data type At 700s At 800s At 900s At 1000s 14 7
8 Declaration of User-defined Data Type struct student { int matr_num; char family_name [20]; char first_name [20]; name of the structure keyword to start the structure declaration components of the structure with different data types char study_course [20]; } ; 15 Access to Structure Components struct student { int matr_num; student_instudycourse is a structured variable consisting of four components. Cells in Main Memory char family_name [20]; student_instudycourse. matr_num student_instudycourse. family_name char first_name [20]; student_instudycourse. first_name char study_course [20]; student_instudycourse. study_course }; struct student student_instudycourse ; Access to each component 16 8
9 Dynamic Data Structures - Linked List - Linked List is a data structure in which each element is dynamically allocated and in which elements point to each other to define a linear relationship Singly- or doubly-linked Stack, queue, circular list 18 9
10 Definition of Linked List (1/2) struct listitem { struct student student_instudycourse; struct listitem *next; }; 19 Definition of Linked List (2/2) Items of list are usually same type Each item points to next item Last item points to null Need head to point to first item! 20 10
11 Head of a Linked List struct listitem { struct student student_instudycourse; struct listitem *next; }; struct listitem *head; 21 Usage of Linked Lists Not massive amounts of data Linear search is okay Sorting not necessary or sometimes not possible Can add and delete data on the fly Even from middle of list 22 11
12 Adding an Item to a List (1/3) Add an item pointed to by q after item pointed to by p Neither p nor q is NULL q p 23 Adding an Item to a List (2/3) Add an item pointed to by q after item pointed to by p q q.next = p.next p 24 12
13 Adding an Item to a List (3/3) Add an item pointed to by q after item pointed to by p q p.next = q p 25 Data structures applied in problem solving 13
14 How to cross the river? 27 Mapping information to data a state indicating the location of items 0: item is at near shore 1: item is at far shore int SHORE[4]={0,0,0,0}; Condition on state transition: Boat can only carry one or none item at a time! > relevant to identify neighboring states 28 14
15 State space model (2 4 = 16 states) (1): Boat: 0 Fox: 0 Goose: 0 Corn: (16): Boat: 1 Fox: 1 Goose: 1 Corn: 1 29 State space model (10 valid/ 6 invalid states) Boat: 0 Fox: 0 Goose: 0 Corn: Boat: 1 Fox: 1 Goose: 1 Corn:
16 Breadth-first search Breadth-first search (BFS) belongs to uninformed (or blind) searching strategies in a graph (a structure made up of nodes connected with edges) does not make use of heuristics for minimizing its computational expensiveness in solving a problem, such as in informed searching approaches begins at a root node and inspects all the neighboring nodes before expanding next level does not explore graph as far as possible along one path before backtracking, such as in depth-first search makes use of queue to manage graph traversal 32 16
17 Queue is a data structure following the FIFO (First In First Out) principle to its elements can be implemented by linked list Queue TAIL n+1 enqueue HEAD TAIL 1 TAIL TAIL n FRONT dequeue HEAD BACK 33 An algorithm for breadth-first search 1. Determine state and add it to QUEUE. 2. Pick head state from QUEUE, add it to QUEUE _visited. a) IF head== then stop and success. b) ELSE add all neighboring states of head to (tail of) QUEUE. 3. IF QUEUE == empty then fail. 4. Repeat
18 Step 1 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat 2. QUEUE QUEUE_visited Boat: 1 Fox: 1 Goose: Head of QUEUE Tail of QUEUE 35 Step 2 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited Strategy #1: Do not consider invalid states
19 Step 3 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE 7 3 QUEUE_visited 7 Strategy #2: Do not consider already visited states again. 37 Step 4 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited
20 Step 5 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited Note: QUEUE_visited does NOT equals THE solution path! 39 Step 6 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited
21 Step 7 of already close to, but Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited Step 8 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat Boat: 1 Fox: 1 Goose: QUEUE (15) 10 QUEUE_visited Strategy #3: Do not consider same head state twice
22 Step 9 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat 2. 2:0001 3:0011 4: :0101 6:0110 7: :1000 9: : : : : : : Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited Step 10 of Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat 2. 2:0001 5:0101 8:1000 9:1001 3:0011 4: :0110 7: : : : : :1111 Boat: :1011 Fox: 1 Goose : 1 Corn: 1 QUEUE QUEUE_visited
23 Final Step: Success 1. Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to (tail of) LIST. 3. IF LIST == empty then fail. 4. Repeat 2. 2:0001 3:0011 4: :0101 6:0110 7: :1000 9: : : : : : : Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited Final Step: Success 1. Determine state and add it to LIST. 2. Pick head state from LIST and add it to LIST_visited. a) IF head== then stop and success. b) ELSE add all (valid) next states to the (tail tricky of) LIST. step 3. IF LIST == empty then fail. 4. Repeat 2. 2:0001 3:0011 4: :0101 6:0110 7: :1000 9: : : : : : : Boat: 1 Fox: 1 Goose: QUEUE QUEUE_visited
24 Finally Applying strategies can reduce time and space complexity of a solution approach Developing solutions is no mechanic procedure, it is a creative act For problem solvers and programmers to be effective: There is not just one way of doing it. 47 of 6th lecture 24
Linked Lists in C and C++
Linked Lists in C and C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by
More informationChapter 19 Data Structures
Chapter 19 Data Structures Img src: reddit.com/r/programmerhumor 19-2 Data Structures A data structure is a particular organization of data in memory. We want to group related items together. We want to
More informationChapter 19 Data Structures -struct -dynamic memory allocation
Chapter 19 Data Structures -struct -dynamic memory allocation Data Structures A data structure is a particular organization of data in memory. We want to group related items together. We want to organize
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationCOMPSCI 210 Part II Data Structure
Agenda & Reading COMPSCI 210 Part II Data Structure Based on slides @ McGraw-Hill Agenda: Enum structs Nested structs Array of structs structs Parameters & Returning structs structs Pointers Exercises:
More information211: Computer Architecture Summer 2016
211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Structure: - header files - global / local variables - main() - macro Basic Units: - basic data types - arithmetic / logical / bit operators
More informationMidterm 1 Review. Introduction to Programming in C. General. Turing Machine. Universal Turing Machine
Midterm 1 Review General Bring student ID card Must have it to check into lab Seating Randomized seating chart Front rows Check when you enter the room Exam No time limit, 100 points NO notes, calculators,
More informationProgramming. Lists, Stacks, Queues
Programming Lists, Stacks, Queues Summary Linked lists Create and insert elements Iterate over all elements of the list Remove elements Doubly Linked Lists Circular Linked Lists Stacks Operations and implementation
More informationCS 231 Data Structures and Algorithms Fall DDL & Queue Lecture 20 October 22, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 DDL & Queue Lecture 20 October 22, 2018 Prof. Zadia Codabux 1 Agenda Mid Semester Analysis Doubly Linked List Queue 2 Administrative None 3 Doubly Linked
More informationCSE 100: GRAPH ALGORITHMS
CSE 100: GRAPH ALGORITHMS 2 Graphs: Example A directed graph V5 V = { V = E = { E Path: 3 Graphs: Definitions A directed graph V5 V6 A graph G = (V,E) consists of a set of vertices V and a set of edges
More information[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 9. Seungkyu Lee. Assistant Professor, Dept. of Computer Engineering Kyung Hee University
[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 9 Seungkyu Lee Assistant Professor, Dept. of Computer Engineering Kyung Hee University CHAPTER 9 Pointers #1~2 Pointer int main () { int a; int b; int c;
More informationLinked Structures. See Section 3.2 of the text.
Linked Structures See Section 3.2 of the text. First, notice that Java allows classes to be recursive, in the sense that a class can have an element which is itself an object of that class: class Person
More informationProcedural Programming
Procedural Programming Lecture 2 - Summer Semester 2016 Control Structures Flow Charts Faculty of Engineering Institute of Computer Engineering What we know so far... Programming is only one step in program
More informationProcedural Programming
Procedural Programming Lecture 2 - Summer Semester 2017 Control Structures Flow Charts Faculty of Engineering Institute of Computer Engineering Practical Training REGISTRATION ends tomorrow Wednesday (26
More informationCP2 Revision. theme: dynamic datatypes & data structures
CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;
More informationCS 1114: Implementing Search. Last time. ! Graph traversal. ! Two types of todo lists: ! Prof. Graeme Bailey.
CS 1114: Implementing Search! Prof. Graeme Bailey http://cs1114.cs.cornell.edu (notes modified from Noah Snavely, Spring 2009) Last time! Graph traversal 1 1 2 10 9 2 3 6 3 5 6 8 5 4 7 9 4 7 8 10! Two
More informationCMPT 225. Lecture 6 linked list
CMPT 225 Lecture 6 linked list 1 Last Lecture Class documentation Linked lists and its operations 2 Learning Outcomes At the end of this lecture, a student will be able to: define one of the concrete data
More informationLargest Online Community of VU Students
WWW.VUPages.com http://forum.vupages.com WWW.VUTUBE.EDU.PK Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions
More information8. Fundamental Data Structures
172 8. Fundamental Data Structures Abstract data types stack, queue, implementation variants for linked lists, [Ottman/Widmayer, Kap. 1.5.1-1.5.2, Cormen et al, Kap. 10.1.-10.2] Abstract Data Types 173
More informationComputer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY
Computer Science Foundation Exam Dec. 19, 2003 COMPUTER SCIENCE I Section I A No Calculators! Name: KEY SSN: Score: 50 In this section of the exam, there are Three (3) problems You must do all of them.
More information! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises Chapters 1-7 + 11 Write C++ code to:! Determine if a number is odd or even CS 2308 Fall 2018 Jill Seaman! Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationCOP 3502 Section 2 Exam #2 Version A Spring /23/2017
COP 3502 Section 2 Exam #2 Version A Spring 2017 3/23/2017 Lecturer: Arup Guha Directions: Answer all multiple choice questions on the scantron. Each question has a single correct answer. In case of ambiguities,
More informationPA3 Design Specification
PA3 Teaching Data Structure 1. System Description The Data Structure Web application is written in JavaScript and HTML5. It has been divided into 9 pages: Singly linked page, Stack page, Postfix expression
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationAshish Gupta, Data JUET, Guna
Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because
More informationLinear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013
Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every
More informationMIDTERM EXAMINATION Spring 2010 CS301- Data Structures
MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the
More informationData Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.
Data Structures Outline Introduction Linked Lists Stacks Queues Trees Introduction dynamic data structures - grow and shrink during execution Linked lists - insertions and removals made anywhere Stacks
More information1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking
Review for Test 2 (Chapter 6-10) Chapter 6: Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B.
More informationIntroduction to Linked Lists
Introduction to Linked Lists In your previous programming course, you organized and processed data items sequentially using an array (or possibly an arraylist, or a vector). You probably performed several
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationCSE 100: GRAPH SEARCH
CSE 100: GRAPH SEARCH Announcements PA3 released Checkpoint due Tuesday, May 5 @10:00pm Final submission due Thursday, May 14 @10:00PM Start early! Start early! Start early! Start early! Start early! I
More informationCS 241 Data Organization Binary Trees
CS 241 Data Organization Binary Trees Brooke Chenoweth University of New Mexico Fall 2017 Binary Tree: Kernighan and Ritchie 6.5 Read a file and count the occurrences of each word. now is the time for
More informationLinear Structures. Linear Structure. Implementations. Array details. List details. Operations 2/10/2013
Linear Structure Linear Structures Chapter 4 CPTR 318 Every non-empty linear structure has A unique element called first A unique element called last Every element except last has a unique successor Every
More informationData Structures Question Bank Multiple Choice
Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution
More informationLesson 3: Understanding General Software Development
Lesson 3: Understanding General Software Development 1. Arrange the various activities of an application lifecycle in the order in which they are likely to occur. a) Requirements analysis, design, coding,
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define
More informationcsci 210: Data Structures Stacks and Queues
csci 210: Data Structures Stacks and Queues 1 Summary Topics Stacks and Queues as abstract data types ( ADT) Implementations arrays linked lists Analysis and comparison Applications: searching with stacks
More information1 P age DS & OOPS / UNIT II
UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular
More informationInformation Science 2
Information Science 2 - Basic Data Structures- Week 02 College of Information Science and Engineering Ritsumeikan University Today s class outline l Basic data structures: Definitions and implementation
More informationCMSC Introduction to Algorithms Spring 2012 Lecture 7
CMSC 351 - Introduction to Algorithms Spring 2012 Lecture 7 Instructor: MohammadTaghi Hajiaghayi Scribe: Rajesh Chitnis 1 Introduction In this lecture we give an introduction to Data Structures like arrays,
More informationCOMP 182 Algorithmic Thinking. Breadth-first Search. Luay Nakhleh Computer Science Rice University
COMP 182 Algorithmic Thinking Breadth-first Search Luay Nakhleh Computer Science Rice University Graph Exploration Elucidating graph properties provides a powerful tool for understanding networks and their
More informationData Structure. IBPS SO (IT- Officer) Exam 2017
Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data
More informationHow to Win Coding Competitions: Secrets of Champions. Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue.
How to Win Coding Competitions: Secrets of Champions Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue. Deque Pavel Krotkov Saint Petersburg 2016 General overview Stack,
More informationIntroduction to Data Structures. Introduction to Data Structures. Introduction to Data Structures. Data Structures
Philip Bille Data Structures Data structure. Method for organizing data for efficient access, searching, manipulation, etc. Goal. Fast. Compact Terminology. Abstract vs. concrete data structure. Dynamic
More informationAn Appropriate Search Algorithm for Finding Grid Resources
An Appropriate Search Algorithm for Finding Grid Resources Olusegun O. A. 1, Babatunde A. N. 2, Omotehinwa T. O. 3,Aremu D. R. 4, Balogun B. F. 5 1,4 Department of Computer Science University of Ilorin,
More information1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?
Review for Final (Chapter 6 13, 15) 6. Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B. To
More informationl Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationBasic Data Structures (Version 7) Name:
Prerequisite Concepts for Analysis of Algorithms Basic Data Structures (Version 7) Name: Email: Concept: mathematics notation 1. log 2 n is: Code: 21481 (A) o(log 10 n) (B) ω(log 10 n) (C) Θ(log 10 n)
More informationChapter 4. Uninformed Search Strategies
Chapter 4. Uninformed Search Strategies An uninformed (a.k.a. blind, brute-force) search algorithm generates the search tree without using any domain specific knowledge. The two basic approaches differ
More information(6-1) Basics of a Queue. Instructor - Andrew S. O Fallon CptS 122 (September 26, 2018) Washington State University
(6-1) Basics of a Queue Instructor - Andrew S. O Fallon CptS 122 (September 26, 2018) Washington State University What is a Queue? 2 A linear data structure with a finite sequence of nodes, where nodes
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 04 / 13 / 2018 Instructor: Michael Eckmann Today s Topics Questions? Comments? Graphs Depth First Search (DFS) Shortest path Shortest weight path (Dijkstra's
More informationCpt S 122 Data Structures. Data Structures
Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours
TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 3 Data Structures Graphs Traversals Strongly connected components Sofya Raskhodnikova L3.1 Measuring Running Time Focus on scalability: parameterize the running time
More informationCS302 Data Structures using C++
CS302 Data Structures using C++ Study Guide for the Final Exam Fall 2018 Revision 1.1 This document serves to help you prepare towards the final exam for the Fall 2018 semester. 1. What topics are to be
More information! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade
Final Exam Review Final Exam Mon, May 5, 2:00PM to 4:30PM CS 2308 Spring 2014 Jill Seaman Closed book, closed notes, clean desk Comprehensive (covers entire course) 30% of your final grade I recommend
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a
More informationUninformed Search Methods
Uninformed Search Methods Search Algorithms Uninformed Blind search Breadth-first uniform first depth-first Iterative deepening depth-first Bidirectional Branch and Bound Informed Heuristic search Greedy
More informationIntroduction to Data Structures
Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays Philip Bille Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays
More informationSYSC 2006 Winter 2012 Linear Collections: Queues
SYSC 2006 Winter 2012 Linear Collections: Queues Copyright 2000-2012 D.L. Bailey, Systems and Computer Engineering, Carleton University revised March 20, 2011, November 28, 2011, March 30, 2012 Definition
More informationCS350 - Exam 1 (100 Points)
Spring 2013 Name CS350 - Exam 1 (100 Points) 1.(25 points) Stacks and Queues (a) (5) For the values 4, 8, 2, 5, 7, 3, 9 in that order, give a sequence of push() and pop() operations that produce the following
More informationCpt S 122 Data Structures. Course Review Midterm Exam # 1
Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 15: Graph Data Structures, Topological Sort, and Traversals (DFS, BFS) Instructor: Lilian de Greef Quarter: Summer 2017 Today: Announcements Graph data structures
More informationChapter 9 STACK, QUEUE
Chapter 9 STACK, QUEUE 1 LIFO: Last In, First Out. Stacks Restricted form of list: Insert and remove only at front of list. Notation: Insert: PUSH Remove: POP The accessible element is called TOP. Stack
More informationBinary Trees (and Big O notation)
Binary Trees (and Big O notation) Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute
More information.:: UNIT 4 ::. STACK AND QUEUE
.:: UNIT 4 ::. STACK AND QUEUE 4.1 A stack is a data structure that supports: Push(x) Insert x to the top element in stack Pop Remove the top item from stack A stack is collection of data item arrange
More informationDynamic Data Structures
Dynamic Data Structures We have seen that the STL containers vector, deque, list, set and map can grow and shrink dynamically. We now examine how some of these containers can be implemented in C++. To
More informationData Structure Advanced
Data Structure Advanced 1. Is it possible to find a loop in a Linked list? a. Possilbe at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Solution: a. Possible at O(n)
More informationHowever, in C we can group related variables together into something called a struct.
CIT 593: Intro to Computer Systems Lecture #21 (11/27/12) Structs Unlike Java, C++, and to some extent Python, C is not traditionally considered an objectoriented language. That is, there is no concept
More informationThe combination of pointers, structs, and dynamic memory allocation allow for creation of data structures
Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation
More informationData Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012
Data Abstractions National Chiao Tung University Chun-Jen Tsai 05/23/2012 Concept of Data Structures How do we store some conceptual structure in a linear memory? For example, an organization chart: 2/32
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 LINKED LISTS LINKED LIST What are the problems with arrays? üsize is fixed üarray items are stored contiguously üinsertions and deletions at particular positions is complex
More informationLesson 1 Introduction to Path Planning Graph Searches: BFS and DFS
Lesson 1 Introduction to Path Planning Graph Searches: BFS and DFS DASL Summer Program Path Planning References: http://robotics.mem.drexel.edu/mhsieh/courses/mem380i/index.html http://dasl.mem.drexel.edu/hing/bfsdfstutorial.htm
More information+ Abstract Data Types
Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract
More information! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises CS 2308 Spring 2014 Jill Seaman Chapters 1-7 + 11 Write C++ code to: Determine if a number is odd or even Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationTHE UNIVERSITY OF WESTERN AUSTRALIA
THE UNIVERSITY OF WESTERN AUSTRALIA MID SEMESTER EXAMINATION April 2018 DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING DATA STRUCTURES AND ALGORITHMS CITS2200 This Paper Contains: 6 Pages 10 Questions
More informationCS24 Week 8 Lecture 1
CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes
More informationPlan. CMPSCI 311: Introduction to Algorithms. Recall. Adjacency List Representation. DFS Descriptions. BFS Description
Plan CMPSCI 311: Introduction to Algorithms Akshay Krishnamurthy and Andrew McGregor University of Massachusetts Review: Breadth First Search Depth First Search Traversal Implementation and Running Time
More informationMID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.
MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions
More informationCOMP 250 Midterm #2 March 11 th 2013
NAME: STUDENT ID: COMP 250 Midterm #2 March 11 th 2013 - This exam has 6 pages - This is an open book and open notes exam. No electronic equipment is allowed. 1) Questions with short answers (28 points;
More informationCS1114 Assignment 3. 1 Previously, on Assignment 2. 2 Linked lists
CS1114 Assignment 3 out: February 25, 2013 due: March 8, 2013 by 5pm 1 Previously, on Assignment 2 In the last assignment we implemented several robust ways of finding the lightstick center. In this assignment,
More informationMatriculation number:
Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse 14 8050 Zurich Phone: +41 44 635 4333 Email: boehlen@ifi.uzh.ch AlgoDat Repetition Exam Spring 2018 18.05.2018 Name: Matriculation number:
More informationCS 310 Advanced Data Structures and Algorithms
CS 31 Advanced Data Structures and Algorithms Graphs July 18, 17 Tong Wang UMass Boston CS 31 July 18, 17 1 / 4 Graph Definitions Graph a mathematical construction that describes objects and relations
More informationLinked Lists and Abstract Data Structures A brief comparison
Linked Lists and Abstract Data A brief comparison 24 March 2011 Outline 1 2 3 4 Data Data structures are a key idea in programming It s just as important how you store the data as it is what you do to
More informationDEPARTMENT OF COMPUTER APPLICATIONS B.C.A. - FIRST YEAR ( REGULATION) SECOND SEMESTER LESSON PLAN SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
DEPARTMENT OF COMPUTER APPLICATIONS B.C.A. - FIRST YEAR (2015-2016 REGULATION) SECOND SEMESTER LESSON PLAN SRM INSTITUTE OF SCIENCE AND TECHNOLOGY FACULTY OF SCIENCE AND HUMANITIES SRM NAGAR, KATTANKULATHUR
More informationLecture 4: Elementary Data Structures Steven Skiena
Lecture 4: Elementary Data Structures Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.stonybrook.edu/ skiena Problem of the Day Find two
More informationSCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING. EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list)
ASSIGNMENT 2 SCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING EKT224: ALGORITHM AND DATA STRUCTURES (Stack, Queue, Linked list) Date: 30/9/2015 Due Date: 30/10/2015 Early Bird Date: 23/10/2015 QUESTION
More informationInsertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue
Queues CSE 2011 Fall 2009 9/28/2009 7:56 AM 1 Queues: FIFO Insertions and removals follow the Fist-In First-Out rule: Insertions: at the rear of the queue Removals: at the front of the queue Applications,
More informationAlgorithms, Data Structures, and Problem Solving
Algorithms, Data Structures, and Problem Solving Masoumeh Taromirad Hamlstad University DT4002, Fall 2016 Container Concepts containers store data container operations: insertion retrieval removal iteration
More informationR13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)
SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)
More informationSome major graph problems
CS : Graphs and Blobs! Prof. Graeme Bailey http://cs.cs.cornell.edu (notes modified from Noah Snavely, Spring 009) Some major graph problems! Graph colouring Ensuring that radio stations don t clash! Graph
More informationIntroduction to Data Structures and Algorithms
Introduction to Data Structures and Algorithms Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures
More information3. Fundamental Data Structures
3. Fundamental Data Structures CH08-320201: Algorithms and Data Structures 233 Data Structures Definition (recall): A data structure is a way to store and organize data in order to facilitate access and
More informationESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists
ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees Instructor: Krithika Venkataramani Semester 2, 2011-2012 1 Introduction to Linked Lists Each bead connected to the next through a
More informationA linear-list Data Structure where - addition of elements to and - removal of elements from are restricted to the first element of the list.
A linear-list Data Structure where - addition of elements to and - removal of elements from are restricted to the first element of the list. the first element of the list a new element to (the Top of)
More informationBachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24
Prepared By ASCOL CSIT 2070 Batch Institute of Science and Technology 2065 Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass
More informationQueues. A queue is a special type of structure that can be used to maintain data in an organized way.
A queue is a special type of structure that can be used to maintain data in an organized way. This data structure is commonly implemented in one of two ways: as an array or as a linked list. In either
More informationDOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE
Chapter 1 : What is an application of linear linked list data structures? - Quora A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements
More informationCPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues
CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 is available.
More information