0% found this document useful (0 votes)
9 views10 pages

W3 Lec2

The document outlines a lecture on data structures and algorithms, focusing on algorithm complexity, arrays, stacks, and queues. It includes a review of asymptotic notation, examples of stack applications like Reverse Polish Notation (RPN), and introduces circular queues. Additionally, it presents assignments related to programming tasks involving queues and stack operations.

Uploaded by

18-QADEER AHMAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

W3 Lec2

The document outlines a lecture on data structures and algorithms, focusing on algorithm complexity, arrays, stacks, and queues. It includes a review of asymptotic notation, examples of stack applications like Reverse Polish Notation (RPN), and introduces circular queues. Additionally, it presents assignments related to programming tasks involving queues and stack operations.

Uploaded by

18-QADEER AHMAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Data Structure and Algorithm

Dr. Rasoo Bukhsh Jatoi


Dated: 29/09/2020

20/10/2020 www.iefr.edu.pk
Today’s Agenda
• Review: Last Lecture
• Stack Application: Reverse Polish Notation (RPN)
• Circular Queue

20/10/2020 www.iefr.edu.pk
Algorithm Complexity-Rview
• Asymptomatic Notation: Mathematical representation of time
complexity
• Prior-analysis of algorithm (without execution)
• Lower Bound, Upper Bound, Best Case, Worst Case, Average Case, Exact
Time, etc.
• No. of times a function is called/statement executes/statements
• Notations: Big oh (O), Big omega (Ω), Big theta (θ)
• Example: last lecture (kx2, x, x+x2 etc. )

20/10/2020 www.iefr.edu.pk
Array-Review
• Contiguous area of memory / Consecutive memory locations
• Consisting of equal-size elements
• Indexed by contiguous integers
• Previously learned, times for operations: Access any element, Add, Remove
Type Arr_Name[]=
Arr_Index 1 2 3 4 5 6 7 8 9 10

• Stack: Last In First Out (LIFO) or First In Last Out (FILO)


• Queue: First Come First Serve (FIFO) or Last Come Last Serve (LILO)

20/10/2020 www.iefr.edu.pk
Examples-Review
• Write a program to print table of input number?
• Write a program of input range of length 10 to print tables of each
number. Hint: input 11-20 (print tables of 11, 12, 13….20) ?

20/10/2020 www.iefr.edu.pk
Stack Application
Precedence
Infix to RPN
A+B * ( C – D )

A B C D - *+
-
(
*
+
Stack

20/10/2020 www.iefr.edu.pk
RPN: Practice
• F=a*c k / p-q*g (h-b)

Operands:F a c k * p q / g h b - *-=
Operators’ Stack:

F=5*23 / 8-6*4(5-3)

20/10/2020 www.iefr.edu.pk
Circular Queue

Type Arr_Name[]=
Arr_Index 1 2 3 4 5 6 7 8 9 10

P1 P2
P2=Push ()
• Over write P1=Pop()
• Re-initialize P1=P2=> ARRAY EMPTY
• No overflow
• No underflow

20/10/2020 www.iefr.edu.pk
Discussion and Question

20/10/2020 www.iefr.edu.pk
Assignment
• Write a program for bank where, a queue of 15 people is formed. The
service requires at least two time visit at counter. You need to make a
automated announcer to call the applicants on counter.

20/10/2020 www.iefr.edu.pk

You might also like