Data Structures
Data Structures
College
SYJC
Computer Science I
Chapter 2: Data Structure
Length = UB – LB + 1
3. E.g.
247 3
500 2
399 1
495 0
Step 5. Exit
Step 6: [Reset N]
Set N := N+1
Step 7: Exit
Step 3: Reset N
N=N-1
Step 4: Exit
Step 4: Exit
Step 5: Exit
Example:
Given DATA array with following 5 elements
11 22 33 44 55
Suppose ITEM = 33
Step 2: LOC = 1
Step 6: Exit
Example:
Given DATA be the following sorted 13 element array:
11 22 30 33 40 44 55 60 66 77 80 88 99
Suppose ITEM = 40
b. E=(2x+y)(a-7b)3
c. E=[(a+b)*c]/[a*((b-c)+a)]
d. E=(x+2y)3-(p+q)
Q11. Explain stacks and Queues.
Ans-
a. Stacks
1. LIFO system is last-in-first-out system.
2. In this system, the element which is inserted at last, will be deleted first.
3. Stack is an example of LIFO system.
4. It is a linear system in which insertion and deletion takes place only at one end
i.e. top of the list.
5. The insertion operation is referred to as push and deletion operation as pop.
6. Example – stack of books.
b. Queue
1. FIFO system is first-in-first-out system.
2. In this system, the element which is inserted first in the list will also be deleted
first.
3. Queue is an FIFO system.
4. A queue is a linear list, in which insertion takes place only at one end of the list
known as ‘rear’ of list and deletion takes place at the other end, called as ‘front’
of the list.
5. Example – A queue for tickets in cinema hall.