Data structures and algorithms lab4

50 %
50 %
Information about Data structures and algorithms lab4

Published on March 9, 2014

Author: Bii03

Source: slideshare.net

DATA STRUCTURES AND ALGORITHMS LAB 4 Bianca Tesila FILS, March 2014

OBJECTIVES Queue  Queue vs stack  Applications 

QUEUES  instance of an abstract data type (ADT) that formalizes the concept of restricted collection (FIFO = first in first out)

QUEUES: BASIC OPERATIONS  enqueue(x)   dequeue()    Removes the element from the head of the queue and returns it Returns an error if the stack is empty peek()   Adds the element x at the tail of the queue Returns (but does not remove) the element at the head of the queue isEmpty()  Returns 1 if the queue is empty and 0 otherwise

QUEUES: IMPLEMENTATION   with a static data structure (array, circular array) with a dynamic data structure (list) ‼Short reminder: Why do we use circular arrays instead of simple arrays?

QUEUES: WITH SIMPLE ARRAYS

QUEUES: WITH CIRCULAR ARRAYS

QUEUES VS STACKS ‼Exercise: Implement a stack using 2 queues. The corresponding class is QueuedStack and has the following methods:  an empty constructor  destructor  push  pop There are several solutions for this task. Using a similar approach, implement a queue using 2 stacks: StackedQueue.

QUEUES AND STACKS: APPLICATIONS ‼Exercise: Implement a stack which provides an efficient get minimum function along with regular push and pop functionality. Hint: use an auxiliary stack. Taking into consideration that a queue can be implemented using 2 stacks, use a similar approach for getting the minimum element out of a queue.

HOMEWORK o Finish all the lab exercises. o Implement a messaging system using queues.   Messages are received in the order they are sent You should use the following classes:        Message MessageSender MessageReceiver A Message object has a sender, recipient, content (make an array of chars!!) and a date A Message is placed in a queue by a MessageSender object A Message is removed from a queue by a MessageReceiver object, which can also display the content of the message. Your queue class can receive any types of objects, including Message Objects

Add a comment

 User name: Comment:

Related pages

DATA STRUCTURES AND ALGORITHMS LAB[1] - Scribd - Read ...

DATA STRUCTURES AND ALGORITHMS LAB[1] - Download as Word Doc (.doc), PDF File (.pdf), Text file (.txt) or read online. Scribd is the world's largest ...
Read more

Data structures and Algorithms | Comp 15 - Data Structures

Lab4; Lab5; Lab6; Lab7; Lab8; Instructor; ... Programs = Algorithms + Data structures -Niklaus Wirth . Code Notes: Intro to Smart Pointers. Code Notes ...
Read more

CSC1051&-&Lab4& - Villanova University

CSC1051 Data Structures and Algorithms I Dr. Papalaskari Fall 2012 !! int a = 10; while (a<10) { System.out.println(a); a++; }!! ...
Read more

Textbooks | Comp 15 - Data Structures - sites.tufts.edu ...

Lab4; Lab5; Lab6; Lab7; Lab8; ... “Data Structures and Algorithm Analysis ... “Data Structures and Other Objects Using C++” ...
Read more

Data Structures And Algorithms Lab Manual

Data Structures and Algorithms in C+, 3rd Edition, Adam animations of various data structures, Lab Manual, Data Structures and Abstractions. Java, 4/E.
Read more

Data Structures and Algorithms - Table of Contents

Data Structures and Algorithms Course Notes, PLDS210 University of Western Australia. ... Data Structures. 3.1 Arrays; 3.2 Lists; 3.3 Stacks. 3.3.1 Stack ...
Read more

Java 101: Datastructures and algorithms, Part 1 | JavaWorld

Computer science emphasizes two important topics: datastructures and algorithms. Those topics are important because the choices you make for a program's ...
Read more

Data Structures And Algorithms Lab Manual For Me Cse

IT2205 Data Structures and Algorithms Lab CS2209 Object Oriented Programming Lab, CS2258 Database Management Systems Lab Anna
Read more