Data Structures and Algorithms

Size: px
Start display at page:

Download "Data Structures and Algorithms"

Transcription

1 Data Structures and Algorithms

2 Circular buffer Circular buffer or ring buffer is a data structure that uses a single, fixed-size buffer like it is connected end-to-end. They are usually used for communication between two sequential processes e.g.: producer - places the information into the circular buffer consumer - takes the information out. It does not shift its elements when one element is consumed, while non-circular buffer does. Overwriting of data in ring buffer is sometimes needed, e.g., producer (e.g., an audio generator) needs to overwrite old data if the consumer (e.g., the sound card) is unable to momentarily keep up.

3 How circular buffer is managed? In general, a circular buffer could be described with: buffer (for data) in memory (dynamically allocated or statically allocated array) start of valid data (pointer or index) end of valid data (pointer or index) The buffer is set empty at the beginning of the communication The producer inserts bytes into the buffer The consumer extracts bytes from the buffer Insertions and extractions can occur in any order.

4 1. Buffer is EMPTY Circular buffer example front rear 2. Insert 1 1 front rear 3. Insert 2, 3, 4 and front rear

5 Circular buffer example 4. Extract 1, 2 and front rear 5. Insert 6, 7 and rear front 6a. Insert 9 => Buffer FULL. Case when REAR + 1 = FRONT. One slot is NOT USED rear front

6 Circular buffer example 6b. Insert 9 and 10 => Is buffer FULL or EMPTY? Additional variable is needed to COUNT data. If COUNT is used then this can be considered as a FULL buffer front rear 6c. Insert 9 and 10 => OVERFLOW. REAR should not pass FRONT. Both should be increased This data is ignored rear front 6d. Insert 9, 10 and 11 => OVERFLOW (case when COUNT is used) front rear

7 Keep One Slot Open This solution always keeps one slot unused. A full buffer has at most (size 1) slots. the buffer is empty if both pointers are pointing at the same location. the buffer is full if the end (rear) pointer, plus one, equals the start (front) pointer. The advantages are: Very simple and robust. Only two pointers/indices are needed The disadvantages are: One slot is left unused

8 Using a Fill Count The fill count is implemented as an additional variable which keeps the number of readable items in the buffer. This variable has to be increased if the write (end) pointer is moved, and to be decreased if the read (start) pointer is moved. In the situation if both pointers pointing at the same location, you consider the fill count to distinguish if the buffer is empty or full. The advantages are: Simple. Needs only one additional variable. The disadvantage is: Third variable needs to be tracked

9 Double Buffering Multiple buffering is the use of more than one buffer to hold a block of data, so that a "reader" will see a complete (though perhaps old) version of the data, rather than a partially-updated version of the data being created by a "writer" In computer graphics term double buffering names a technique used for drawing graphics to avoid flickering, tearing and other artifacts. In a software implementation of double buffering, all drawing operations are done in some region of RAM which is often called a "back buffer". When all drawing is completed, the whole region (or only the changed portion) is copied into the video RAM (the "front buffer") Double buffering necessarily requires: more RAM needed (for back buffer ) the more CPU time for the copy operation time waiting for monitor s vertical blank interval

10 Page flipping Sometimes called ping-pong buffering In this method instead of copying the data, both buffers are capable of being displayed (both are in Video RAM). At any time, one buffer is actively being displayed by the monitor, while the other, background buffer is being drawn. When drawing is complete, the roles of the two are switched. The page-flip is typically accomplished by modifying the value of a pointer to the beginning of the display data in the video memory. The page-flip is much faster than copying the data and can guarantee that tearing will not be seen as long as the pages are switched over during the monitor's vertical blank period when no video data is being drawn. The currently active and visible buffer is called the front buffer, while the background page is called the back buffer.

11 Not only in computer graphics When not used in computer graphics, the idea about using multiple buffers is that data is inserted into one buffer while data is extracted from another. Multiple buffers are used when the read and write operations are performed asynchronously, usually by two different processors, e.g. communication processor and CPU. For example: a communications processor/engine (USB, UART, etc.) receives data to buffer A, while CPU process data from buffer B. After buffer A is full, it is told to switch to buffer B and to receive data in it. a communications processor/engine (USB, UART, etc.) receives data to buffer B, while CPU process data from buffer A.

12 Linked List A linked list is a data structure in which: Successive nodes (elements) are connected by pointers Last node points to NULL. It can grow or shrink in size during execution of a program. It can be made just as long as required, free memory is a limit It does not waste memory space. Head

13 Linked List It is abstract data type because: It has defined functions for doing operation on the list, e.g. insert node, delete node etc. Details of how the list is implemented or how the functions are implemented are hidden and not important as long as they do what is specified Common linked lists operations are: Creating a list Destroying a list Inserting node Deleting node Keeping track of a linked list: Must know the pointer to the first node of the list (called start, head, etc.)

14 Types of list Several different types of linked lists are possible: singly-linked list last node points to NULL Head

15 Types of list circular linked list - The pointer from the last node in the list points back to the first node Head

16 Types of list Doubly linked list Pointers exist between adjacent nodes in both directions. The list can be traversed either forward or backward Usually two pointers are maintained to keep track of the list, head and tail. Head Tail

17 Array vs. Linked list Arrays are suitable for: Inserting/deleting node at the end. Randomly accessing any node (by index) Linked lists are suitable for: Inserting/deleting node anywhere in the list Applications where sequential access is required. In situations where the number of nodes cannot be predicted beforehand.

18 Creating the list Structure that represent list node should be defined typedef struct _node { /* put data fields here */ struct _node *next; /* points to the next node */ }node; Structure needed for storing data necessary for list handling should be created too struct list { node *head; /* points to the first node in the list */ node *tail; /* points to the last node in the list */ int count; /* represent number of nodes in the list */ }; For N nodes nodes following should be done: Allocate n nodes, one by one. Initialize the fields of the nodes. Modify the links of the nodes so that the chain is formed. Set head to point to the first node

19 How to traverse through the list? In order to traverse the list do the following: Start from head or tail (if exists) Follow the links Process the data of the nodes as they are traversed Stop when the next pointer points to NULL, if list is not circular

20 Inserting node Node to insert Node to insert

21 Inserting node in the list Following situations are possible: Inserting node at the beginning Head is made to point to the new node. New node points to the previously first element. Inserting node at the end, Last node now points to the new node. New node points to NULL. Inserting in the middle Previous node now points to the new node. New node points to the next node. NOTE: either unique value (key) is given the node in order to identify before which node new node should be inserted, or requested position of the new node in the list is used.

22 Deleting node Node to delete

23 Deleting node from the list Following situations are possible: Deleting node at the beginning Head is made to point to the next node. Deleting node at the end Node before last (deleted) node now points to NULL. Deleting node in the middle Previous node now points to the next node. NOTE: either unique value (key) is given or position of the new node is used in order to identify which node should be deleted.

24 Queue The queue is an abstract data structure. A physical analogy for a queue is a line at a bank. When you go to the bank, customers go to the rear (end) of the line and customers come off of the line (i.e., are serviced) from the front of the line. Common queue operations are: Enter (Add) - Places an object at the rear (tail) of the queue. Delete (Remove) - Removes an object from the front (head) of the queue and produces that object. IsEmpty - Reports whether the queue is empty or not.

25 Queue Queues produce a certain order in which content of the queue is used. Let's check that order by looking at a queue of letters... Lets start with the queue that has 3 letters in it. a b c front rear Now, Enter(queue, 'd')... a b c d front rear

26 Now, ch = Delete(queue)... Queue b c d a ch front rear Queue enforces a FIFO order to the use of its contents, i.e., the First thing In is the First thing Out (FIFO) order.

27 Queue Array Implementation Array of a fixed size is used, in this example size of 4 is used Number of elements in the queue is necessary to keep track of the queue. We'll start with a queue with 3 elements entered (added): a b c count where 'a' is at the front and 'c' is at the rear.

28 Enter a new element with: Enter(queue, 'd')... Queue Array Implementation a b c d count Remove an element with: ch = Delete(queue)... b c d count a ch

29 Queue Array Implementation Now there is a problem because the front of the queue is no longer at array position 0. One solution would be to move all the elements down one, giving: b c d count That is BAD SOLUTION because it is too expensive to move everything down every time we remove an element. Question: Can we use an additional piece of information to keep track of the front? Answer: Yes! We can use the index of the element at the front, giving: b c d front 3 count

30 Queue Array Implementation Enter another element with: Enter(queue, 'e')? Question: Where will we put 'e' since moving everything down is too expensive? Answer: Array will be used in circular fashion, so when the end of the array is hit, it is wrapped around. Now, with this choice for entering 'e', the fields look like: e b c d front 4 count Delete element: ch = Delete(queue)? e c d 2 3 b front count ch

31 Queue - Linked-List Implementation Here is an example singly-linked list that holds characters. a b c Beginning of the linked list will be the front of the queue and the end of the linked list will be rear of the queue. Initilly, pointer that points to the first value will be renamed to front a b c front

32 Queue - Linked-List Implementation Question: Will this representation be sufficient for adding and removing things from the queue? Answer: Yes, however, we see one inefficiency in that, to add something to a queue, that thing must go on the rear and the only way to get to the end is to traverse to the end of the list. To be more efficient track of the rear of the queue should be kept with a direct link. Then queue will look as follows: a b c front rear If queue is empty, front and rear should link to nothing.

33 Stack The stack is an abstract data structure. One way to describe how a stack data structure behaves is to look at a physical analogy, a stack of books...imagine we have 4 of them on the stack. Pulling out the 3 rd book from the top cannot be done directly because the stack might fall over. Instead, 3 rd book can be reached by taking books from the top of the pile, one by one. Common stack operations are: Push: Places an object on the top of the stack. Pop: Removes an object from the top of the stack IsEmpty: Reports whether the stack is empty or not.

34 Stack Stack produce a certain order in which content of the stack is used. Let's check that order by looking at a queue of letters... Lets start with stack which is empty: Put letter A with Push(stack, A): a top

35 Stack Again, another push operation, Push(stack, B), giving: b a top Now let's remove an item, ch = Pop(stack): a top b ch One more addition, Push(stack, C): c a One more removal, ch = Pop(stack): a top top c ch Stack enforces LIFO order to the use of its contents, i.e., the Last thing In is the First thing Out (LIFO) order.

36 Stack Array Implementation Array of a fixed size is used, in this example size of 4 is used Initially array has a and b in it: a b Question: Is array sufficient, or will we need to store more information concerning the stack? Answer: We need to keep track of the top of the stack

37 Stack Array Implementation Now we have a b top Since b is at the top of the stack, the value top stores the index of b in the array (i.e., 1). Push something on the stack with Push(stack, c'): a b c top Both, the contents and top are changed.

38 Stack Array Implementation Sequence of pops produce the following effects: ch = Pop(stack) a b ch = Pop(stack) a ch = Pop(stack) So, when the stack is empty top is top 0 top -1 top c ch b ch a ch

39 Stack Array Implementation Question: What happens if we apply the following set of operations? Push(stack, 'd') Push(stack, 'e') Push(stack, 'f') Push(stack, 'g') d e f g top ch and then try to add H with Push(stack, h')? Answer: There is no more space on the stack to store h Disadvantage of using an static array to implement a stack is limited size of the stack. That can be avoided by using dynamically allocated arrays

40 Stack Linked List Implementation When using linked list to implement a stack essentially any number of elements could be handled Here is what a linked list implementing a stack with 3 elements might look like: a b c Question: Where the top of the stack should be, at the beginning or end of the list? Answer: Top should be at the beginning Question: How to represent an empty stack? Answer: Top is NULL

41 Event-driven Finite State Machine (FSM) FSM is a behavior model composed of: finite number of states definitions of transitions between those states actions taken in particular states on particular events FSM cycle is as following: begins from one of the states (called a start state) executes actions upon the occurred event goes through transitions in response to events and current states ends up in required states

42 FSM It is probably easiest to understand state machines by examining the graphical depiction, known as a Finite State Diagram (FSD) or State Transition Diagram (STD), of a simple example. The Digital Lock FSM from example can be in one of the following states: NoneRight OneRight TwoRight Open The arrows between the state bubbles represent the transitions, labeled with the event that triggers that transition. The bubbles represent the states. While in a state, the FSM is waiting for an event to cause it to transition

43 FSM Best approach is to use nested IF/CASE structures in which FSM states are represented as different clauses/cases. Within each of those state clauses there is nested IF/CASE structure that handle the events that could occur while in that state. This combination of nested IF/CASE structures are wrapped inside a function that maintains a static local variable to track the current state of the machine. See example fsm.c

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

More information

DATA STRUCTURES USING C

DATA STRUCTURES USING C DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

More information

QUEUES. Primitive Queue operations. enqueue (q, x): inserts item x at the rear of the queue q

QUEUES. Primitive Queue operations. enqueue (q, x): inserts item x at the rear of the queue q QUEUES A queue is simply a waiting line that grows by adding elements to its end and shrinks by removing elements from the. Compared to stack, it reflects the more commonly used maxim in real-world, namely,

More information

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E. Chapter 5 Linked Lists Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given

More information

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Linked Lists, Stacks, Queues, Deques. It s time for a chainge! Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems

More information

10CS35: Data Structures Using C

10CS35: Data Structures Using C CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types EECS 281: Data Structures and Algorithms The Foundation: Data Structures and Abstract Data Types Computer science is the science of abstraction. Abstract Data Type Abstraction of a data structure on that

More information

Analysis of a Search Algorithm

Analysis of a Search Algorithm CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

More information

Common Data Structures

Common Data Structures Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees

More information

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. 1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

More information

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes. 1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

More information

Universidad Carlos III de Madrid

Universidad Carlos III de Madrid Universidad Carlos III de Madrid Algorithms and Data Structures (ADS) Bachelor in Informatics Engineering Computer Science Department Lists, Stacks and Queues. Authors: Isabel Segura Bedmar April 2011

More information

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate

More information

Module 2 Stacks and Queues: Abstract Data Types

Module 2 Stacks and Queues: Abstract Data Types Module 2 Stacks and Queues: Abstract Data Types A stack is one of the most important and useful non-primitive linear data structure in computer science. It is an ordered collection of items into which

More information

PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC QUESTION BANK PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

More information

Linked Lists Linked Lists, Queues, and Stacks

Linked Lists Linked Lists, Queues, and Stacks Linked Lists Linked Lists, Queues, and Stacks CSE 10: Introduction to C Programming Fall 200 Dynamic data structure Size is not fixed at compile time Each element of a linked list: holds a value points

More information

Data Structures and Data Manipulation

Data Structures and Data Manipulation Data Structures and Data Manipulation What the Specification Says: Explain how static data structures may be used to implement dynamic data structures; Describe algorithms for the insertion, retrieval

More information

What is a Stack? Stacks and Queues. Stack Abstract Data Type. Java Interface for Stack ADT. Array-based Implementation

What is a Stack? Stacks and Queues. Stack Abstract Data Type. Java Interface for Stack ADT. Array-based Implementation Stacks and Queues What is a Stack? Stores a set of elements in a particular order Accessed in Last-In In-First-Out (LIFO) fashion Real life examples: Pile of books PEZ dispenser Cup trays in cafeteria

More information

22c:31 Algorithms. Ch3: Data Structures. Hantao Zhang Computer Science Department http://www.cs.uiowa.edu/~hzhang/c31/

22c:31 Algorithms. Ch3: Data Structures. Hantao Zhang Computer Science Department http://www.cs.uiowa.edu/~hzhang/c31/ 22c:31 Algorithms Ch3: Data Structures Hantao Zhang Computer Science Department http://www.cs.uiowa.edu/~hzhang/c31/ Linear Data Structures Now we can now explore some convenient techniques for organizing

More information

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

CHAPTER 4 ESSENTIAL DATA STRUCTRURES CHAPTER 4 ESSENTIAL DATA STRUCTURES 72 CHAPTER 4 ESSENTIAL DATA STRUCTRURES In every algorithm, there is a need to store data. Ranging from storing a single value in a single variable, to more complex

More information

Communication Protocol

Communication Protocol Analysis of the NXT Bluetooth Communication Protocol By Sivan Toledo September 2006 The NXT supports Bluetooth communication between a program running on the NXT and a program running on some other Bluetooth

More information

Application of Stacks: Postfix Expressions Calculator (cont d.)

Application of Stacks: Postfix Expressions Calculator (cont d.) Application of Stacks: Postfix Expressions Calculator (cont d.) Postfix expression: 6 3 + 2 * = FIGURE 7-15 Evaluating the postfix expression: 6 3 + 2 * = Data Structures Using C++ 2E 1 Application of

More information

Getting Started on the Computer With Mouseaerobics! Windows XP

Getting Started on the Computer With Mouseaerobics! Windows XP This handout was modified from materials supplied by the Bill and Melinda Gates Foundation through a grant to the Manchester City Library. Getting Started on the Computer With Mouseaerobics! Windows XP

More information

Data Structure [Question Bank]

Data Structure [Question Bank] Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:

More information

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A

More information

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016 CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues Linda Shapiro Registration We have 180 students registered and others who want to get in. If you re thinking of dropping

More information

DATA STRUCTURE - STACK

DATA STRUCTURE - STACK DATA STRUCTURE - STACK http://www.tutorialspoint.com/data_structures_algorithms/stack_algorithm.htm Copyright tutorialspoint.com A stack is an abstract data type ADT, commonly used in most programming

More information

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) -----------------------------------------

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push) ----------------------------------------- =============================================================================================================================== DATA STRUCTURE PSEUDO-CODE EXAMPLES (c) Mubashir N. Mir - www.mubashirnabi.com

More information

Queues and Stacks. Atul Prakash Downey: Chapter 15 and 16

Queues and Stacks. Atul Prakash Downey: Chapter 15 and 16 Queues and Stacks Atul Prakash Downey: Chapter 15 and 16 Queues Queues occur in real life a lot. Queues at checkout Queues in banks In software systems: Queue of requests at a web servers Properties of

More information

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks

PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks PROGRAMMING CONCEPTS AND EMBEDDED PROGRAMMING IN C, C++ and JAVA: Lesson-4: Data Structures: Stacks 1 STACK A structure with a series of data elements with last sent element waiting for a delete operation.

More information

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2) Chapter 7 Data Structures for Computer Graphics (This chapter was written for programmers - option in lecture course) Any computer model of an Object must comprise three different types of entities: 1.

More information

Unordered Linked Lists

Unordered Linked Lists Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 13-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 13-1 Slide 13-1 Chapter 13 Disk Storage, Basic File Structures, and Hashing Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and Extendible

More information

Node-Based Structures Linked Lists: Implementation

Node-Based Structures Linked Lists: Implementation Linked Lists: Implementation CS 311 Data Structures and Algorithms Lecture Slides Monday, March 30, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org

More information

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 2005-2006 / Semester

More information

Lecture 12 Doubly Linked Lists (with Recursion)

Lecture 12 Doubly Linked Lists (with Recursion) Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)

More information

Chapter 13 Disk Storage, Basic File Structures, and Hashing.

Chapter 13 Disk Storage, Basic File Structures, and Hashing. Chapter 13 Disk Storage, Basic File Structures, and Hashing. Copyright 2004 Pearson Education, Inc. Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files

More information

STACKS,QUEUES, AND LINKED LISTS

STACKS,QUEUES, AND LINKED LISTS STACKS,QUEUES, AND LINKED LISTS Stacks Queues Linked Lists Double-Ended Queues Case Study: A Stock Analysis Applet 1 Stacks Astack is a container of objects that are inserted and removed according to the

More information

Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1

Course: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1 Definition Course: Programming II - Abstract Data Types The ADT Stack The ADT Stack is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit insertions

More information

7.1 Our Current Model

7.1 Our Current Model Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.

More information

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and: Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

More information

Introduction to Data Structures and Algorithms

Introduction to Data Structures and Algorithms Introduction to Data Structures and Algorithms Chapter: Elementary Data Structures(1) Lehrstuhl Informatik 7 (Prof. Dr.-Ing. Reinhard German) Martensstraße 3, 91058 Erlangen Overview on simple data structures

More information

Chapter 1 Computer System Overview

Chapter 1 Computer System Overview Operating Systems: Internals and Design Principles Chapter 1 Computer System Overview Eighth Edition By William Stallings Operating System Exploits the hardware resources of one or more processors Provides

More information

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E. Chapter 5 Linked Lists Data Structures Using C++ 2E Chapter 5 Linked Lists Test #1 Next Thursday During Class Cover through (near?) end of Chapter 5 Objectives Learn about linked lists Become aware of the basic properties of

More information

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic Queues Outline and Required Reading: Queues ( 4. except 4..4) COSC, Fall 3, Section A Instructor: N. Vlajic Queue ADT Queue linear data structure organized according to first-in/first-out (FIFO) principle!

More information

Sequential Data Structures

Sequential Data Structures Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year

More information

Computer Programming using C

Computer Programming using C Computer Programming using C Lecture 11: Buffers and linked lists: solutions Dr Julian Miller Room P/M/101 Ext 2383; E-mail: jfm@ohm http://www.elec.york.ac.uk/intsys/users/jfm7 Contents Solution to buffers

More information

DATA STRUCTURE - QUEUE

DATA STRUCTURE - QUEUE DATA STRUCTURE - QUEUE http://www.tutorialspoint.com/data_structures_algorithms/dsa_queue.htm Copyright tutorialspoint.com Queue is an abstract data structure, somewhat similar to stack. In contrast to

More information

Chapter 13. Disk Storage, Basic File Structures, and Hashing

Chapter 13. Disk Storage, Basic File Structures, and Hashing Chapter 13 Disk Storage, Basic File Structures, and Hashing Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and Extendible Hashing

More information

Record Storage and Primary File Organization

Record Storage and Primary File Organization Record Storage and Primary File Organization 1 C H A P T E R 4 Contents Introduction Secondary Storage Devices Buffering of Blocks Placing File Records on Disk Operations on Files Files of Unordered Records

More information

EZ DUPE DVD/CD Duplicator

EZ DUPE DVD/CD Duplicator EZ DUPE DVD/CD Duplicator User s Manual Version 3.0 0 TABLE OF CONTENTS Introduction 2 Setup 11 LCD Front Panel Overview 2 o Auto Start Time 11 Menu Overview 3-5 o Display Mode 12 Functions 6 o Button

More information

CD/DVD Disc Duplicator Controller

CD/DVD Disc Duplicator Controller CD/DVD Disc Duplicator Controller USERS MANUAL Introduction Features Model & Specification Control Panel Menu Overview Operation Guide 1. Copy 2. Test 3. Copy & Verify 4. Copy & compare 5. Verify 6. Compare

More information

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Data Structure By Ajay Raiyani Yogidham, Kalawad Road, Rajkot. Ph : 572365, 576681 1 Linked List 4 Singly Linked List...4 Doubly Linked List...7 Explain Doubly Linked list: -...7 Circular Singly Linked

More information

Chapter 3: Restricted Structures Page 1

Chapter 3: Restricted Structures Page 1 Chapter 3: Restricted Structures Page 1 1 2 3 4 5 6 7 8 9 10 Restricted Structures Chapter 3 Overview Of Restricted Structures The two most commonly used restricted structures are Stack and Queue Both

More information

Basic Data Structures and Algorithms

Basic Data Structures and Algorithms Tutorial 3 Basic Data Structures and Algorithms THINGS TO LOOK FOR 3.0 INTRODUCTION 3.1 Array Based Containers Definition and uses of containers. Array and list based containers. Designing and building

More information

Scheduling. Getting Started. Scheduling 79

Scheduling. Getting Started. Scheduling 79 Scheduling 9 Scheduling An event planner has to juggle many workers completing different tasks, some of which must be completed before others can begin. For example, the banquet tables would need to be

More information

Chapter 13: Query Processing. Basic Steps in Query Processing

Chapter 13: Query Processing. Basic Steps in Query Processing Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing

More information

recursion, O(n), linked lists 6/14

recursion, O(n), linked lists 6/14 recursion, O(n), linked lists 6/14 recursion reducing the amount of data to process and processing a smaller amount of data example: process one item in a list, recursively process the rest of the list

More information

Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor

Data Structures. Level 6 C30151. www.fetac.ie. Module Descriptor The Further Education and Training Awards Council (FETAC) was set up as a statutory body on 11 June 2001 by the Minister for Education and Science. Under the Qualifications (Education & Training) Act,

More information

CPS122 Lecture: State and Activity Diagrams in UML

CPS122 Lecture: State and Activity Diagrams in UML CPS122 Lecture: State and Activity Diagrams in UML Objectives: last revised February 14, 2012 1. To show how to create and read State Diagrams 2. To introduce UML Activity Diagrams Materials: 1. Demonstration

More information

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: 3330704)

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: 3330704) GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT Course Curriculum DATA STRUCTURES (Code: 3330704) Diploma Programme in which this course is offered Semester in which offered Computer Engineering,

More information

Embroidery Fonts Plus ( EFP ) Tutorial Guide Version 1.0505

Embroidery Fonts Plus ( EFP ) Tutorial Guide Version 1.0505 Embroidery Fonts Plus ( EFP ) Tutorial Guide Version 1.0505 1 Contents Chapter 1 System Requirements.................. 3 Chapter 2 Quick Start Installation.................. 4 System Requirements................

More information

Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative

More information

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure Short Notes on Dynamic Memory Allocation, Pointer and Data Structure 1 Dynamic Memory Allocation in C/C++ Motivation /* a[100] vs. *b or *c */ Func(int array_size) double k, a[100], *b, *c; b = (double

More information

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number

More information

Creating and Using Master Documents

Creating and Using Master Documents Creating and Using Master Documents Title: Creating and Using Master Documents Version: 0.3 First edition: 09/04 Contents Overview...2 Acknowledgments...2 Modifications and updates... 2 Why use a master

More information

Umbrello UML Modeller Handbook

Umbrello UML Modeller Handbook 2 Contents 1 Introduction 7 2 UML Basics 8 2.1 About UML......................................... 8 2.2 UML Elements........................................ 9 2.2.1 Use Case Diagram.................................

More information

D06 PROGRAMMING with JAVA

D06 PROGRAMMING with JAVA Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch20 Data Structures I PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for

More information

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues 1. 2004 Goodrich, Tamassia

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues 1. 2004 Goodrich, Tamassia This lecture Abstract data types Stacks Queues ADTs, Stacks, Queues 1 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations

More information

Chapter 13. Chapter Outline. Disk Storage, Basic File Structures, and Hashing

Chapter 13. Chapter Outline. Disk Storage, Basic File Structures, and Hashing Chapter 13 Disk Storage, Basic File Structures, and Hashing Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Chapter Outline Disk Storage Devices Files of Records Operations on Files Unordered Files

More information

Data Structure with C

Data Structure with C Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

More information

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.

More information

St S a t ck a ck nd Qu Q eue 1

St S a t ck a ck nd Qu Q eue 1 Stack and Queue 1 Stack Data structure with Last-In First-Out (LIFO) behavior In Out C B A B C 2 Typical Operations Pop on Stack Push isempty: determines if the stack has no elements isfull: determines

More information

University of Dublin Trinity College. Storage Hardware. Owen.Conlan@cs.tcd.ie

University of Dublin Trinity College. Storage Hardware. Owen.Conlan@cs.tcd.ie University of Dublin Trinity College Storage Hardware Owen.Conlan@cs.tcd.ie Hardware Issues Hard Disk/SSD CPU Cache Main Memory CD ROM/RW DVD ROM/RW Tapes Primary Storage Floppy Disk/ Memory Stick Secondary

More information

Reviewing documents with track changes in Word 2013

Reviewing documents with track changes in Word 2013 Reviewing documents with track changes in Word 2013 Information Services Reviewing documents with track changes in Word 2013 This note covers how to use Word s reviewing tools to track the changes made

More information

Operating Systems CSE 410, Spring 2004. File Management. Stephen Wagner Michigan State University

Operating Systems CSE 410, Spring 2004. File Management. Stephen Wagner Michigan State University Operating Systems CSE 410, Spring 2004 File Management Stephen Wagner Michigan State University File Management File management system has traditionally been considered part of the operating system. Applications

More information

Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure

More information

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

Questions 1 through 25 are worth 2 points each. Choose one best answer for each. Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

File System Management

File System Management Lecture 7: Storage Management File System Management Contents Non volatile memory Tape, HDD, SSD Files & File System Interface Directories & their Organization File System Implementation Disk Space Allocation

More information

How to design and implement firmware for embedded systems

How to design and implement firmware for embedded systems How to design and implement firmware for embedded systems Last changes: 17.06.2010 Author: Rico Möckel The very beginning: What should I avoid when implementing firmware for embedded systems? Writing code

More information

Data Structures and Algorithms Stacks and Queues

Data Structures and Algorithms Stacks and Queues Data Structures and Algorithms Stacks and Queues Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/23 6-0: Stacks and

More information

LINKED DATA STRUCTURES

LINKED DATA STRUCTURES LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

More information

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY A PATH FOR HORIZING YOUR INNOVATIVE WORK A REVIEW ON THE USAGE OF OLD AND NEW DATA STRUCTURE ARRAYS, LINKED LIST, STACK,

More information

Data Structures Using C++

Data Structures Using C++ Data Structures Using C++ 1.1 Introduction Data structure is an implementation of an abstract data type having its own set of data elements along with functions to perform operations on that data. Arrays

More information

Chapter 2: OS Overview

Chapter 2: OS Overview Chapter 2: OS Overview CmSc 335 Operating Systems 1. Operating system objectives and functions Operating systems control and support the usage of computer systems. a. usage users of a computer system:

More information

List, Stack and Queue. Tom Chao Zhou CSC2100B Data Structures Tutorial 3

List, Stack and Queue. Tom Chao Zhou CSC2100B Data Structures Tutorial 3 List, Stack and Queue Tom Chao Zhou CSC2100B Data Structures Tutorial 3 Outline Structure Linked List Overview Implementation Stack Overview Implementation Queue Overview Implementation Structure A collection

More information

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92. Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

More information

Physical Data Organization

Physical Data Organization Physical Data Organization Database design using logical model of the database - appropriate level for users to focus on - user independence from implementation details Performance - other major factor

More information

Lecture Notes on Stacks & Queues

Lecture Notes on Stacks & Queues Lecture Notes on Stacks & Queues 15-122: Principles of Imperative Computation Frank Pfenning, André Platzer, Rob Simmons Lecture 9 February 12, 2013 1 Introduction In this lecture we introduce queues and

More information

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation Dynamic Storage Allocation CS 44 Operating Systems Fall 5 Presented By Vibha Prasad Memory Allocation Static Allocation (fixed in size) Sometimes we create data structures that are fixed and don t need

More information

Stack Allocation. Run-Time Data Structures. Static Structures

Stack Allocation. Run-Time Data Structures. Static Structures Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

Efficient Data Structures for Decision Diagrams

Efficient Data Structures for Decision Diagrams Artificial Intelligence Laboratory Efficient Data Structures for Decision Diagrams Master Thesis Nacereddine Ouaret Professor: Supervisors: Boi Faltings Thomas Léauté Radoslaw Szymanek Contents Introduction...

More information

Last not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever!

Last not not Last Last Next! Next! Line Line Forms Forms Here Here Last In, First Out Last In, First Out not Last Next! Call stack: Worst line ever! ECE 551 C++ Programming, Data structures, and Algorithms Abstract Data Type: Stack Last In First Out (LIFO) 1 2 2 1 4 3 1 3 4 Stacks in Programming Worst line ever! 5 3 1 5 Stacks are not useful for waiting

More information

Chapter 11 I/O Management and Disk Scheduling

Chapter 11 I/O Management and Disk Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 11 I/O Management and Disk Scheduling Dave Bremer Otago Polytechnic, NZ 2008, Prentice Hall I/O Devices Roadmap Organization

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

IT Quick Reference Guides Using Windows 7

IT Quick Reference Guides Using Windows 7 IT Quick Reference Guides Using Windows 7 Windows Guides This sheet covers many of the basic commands for using the Windows 7 operating system. WELCOME TO WINDOWS 7 After you log into your machine, the

More information