STACK – ARRAY

STACK – INSERTION- PUSH

STACK – DELETION - POP

STEP 1: CHECK STACK “OVERFLOW”

STEP 1: CHECK STACK “OVERFLOW”

STEP 2: IF TOP < MAX-1 THEN

STEP 2: IF TOP < 0

INCREMENT TOP BY 1

TEMP_DATA = STACK[TOP]

STEP 3: PUSH STACK[TOP]=NEW_DATA

STEP 3: DECREMENT TOP BY 1

STEP 4: ASSIGN S_TOP=TOP

STEP 4: ASSIGN S_TOP=TOP

STEP 5: ASSIGN S_DATA=STACK[TOP]

STEP 5: ASSIGN S_DATA=STACK[TOP] STEP 6: FREE/DELETE TEMP_DATA

Mark top on each operation with  Top 3

3

3

3

2

2

2

2

1

1

1

1

0

0

0

0

S_Top =

S_Top =

S_Top =

S_Top =

S_Data =

S_Data =

S_Data =

S_Data =

3

3

3

3

2

2

2

2

1

1

1

1

0

0

0

0

S_Top =

S_Top =

S_Top =

S_Top =

S_Data =

S_Data =

S_Data =

S_Data =

QUEUE

QUEUE – INSERTION- ENQUEUE

QUEUE – DELETION - DEQUEUE

STEP 1: CHECK QUEUE IS “FULL”

STEP 1: CHECK QUEUE IS “EMPTY”

STEP 2: IF FRONT = REAR = -1, THEN

STEP 2: IF FRONT < MAX && FRONT <=

SET FRONT = FRONT + 1

REAR THEN

SET REAR = REAR + 1

TEMP_DATA = QUEUE[FRONT]

QUEUE[REAR]= NEW_DATA

SET FRONT = FRONT + 1

STEP 3: IF REAR < MAX-1 THEN

STEP 3:FREE / DELETE TEMP_DATA

SET REAR = REAR + 1

STEP 4: ELSE PRINT “DELETION

QUEUE[REAR]= NEW_DATA

IMPOSSIBLE”

Initially front = rear = -1 0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

0

1

2

3

4 FRONT = REAR =

CIRCULAR QUEUE

CIRCULAR QUEUE – INSERTION STEP 1: IF FRONT==0 AND REAR = MAX-1, THEN WRITE “OVERFLOW” ELSE IF FRONT ==-1 AND REAR ==-1, THEN SET FRONT = REAR = 0 ELSE IF REAR == MAX-1 AND FRONT !=0, THEN SET REAR = 0 ELSE SET REAR = REAR +1 [END OF IF]

CIRCULAR QUEUE – DELETION STEP 1: IF FRONT = -1, THEN WRITE “UNDERFLOW”, SET VAL = -1 [END OF IF] STEP 2: SET VAL = QUEUE[FRONT] STEP 3: IF FRONT == REAR, THEN SET FRONT = REAR = -1 ELSE

STPE 2: SET QUEUE[REAR] = NEW_DATA

IF FRONT = MAX -1,

STEP 3: EXIT

THEN SET FRONT =0 ELSE SET FRONT = FRONT + 1 [END OF IF] [END OF IF]

0

1

0

1

3

2

3

2

0

1

0

1

3

2

3

2

0

1

0

1

3

2

3

2

UNIT - V SORTING BUBBLE SORT - ALGORITHM STEP 1: START STEP 2: REPEAT FOR I =0 TO N-1 STEP 3: REPEAT FOR J=0 TO N-1 STEP 4: IF ARR[ J ] > ARR[ J+1 ] THEN 4.1 TEMP= ARR[ J ] 4.2 ARR[ J ] = ARR[ J+1 ] 4.3 ARR[ J+1 ]=TEMP [ END OF IF ] 3.1 [ END OF INNER LOOP J ] 2.1 [ END OF OUTER LOOP ] STEP 5: EXIT

0

1

2

I = 0; J / ARR[ J ]

0

J+1/ ARR[ J + 1 ]

1

Condition

2

If true, Swap

3

Sorted Array

4

I = 1; J / ARR[ J ]

0

J+1/ ARR[ J + 1 ]

1

Condition

2

If true, Swap

3

Sorted Array

4

3

4

I = 2; J / ARR[ J ]

0

J+1/ ARR[ J + 1 ]

Condition

1

2

If true, Swap

3

Sorted Array

4

I = 3; J / ARR[ J ]

0

J+1/ ARR[ J + 1 ]

Condition

1

2

If true, Swap

3

Sorted Array

4

I = 4; J / ARR[ J ]

0

J+1/ ARR[ J + 1 ]

1

Condition

2

If true, Swap

3

Sorted Array

4

INSERTION SORT - ALGORITHM STEP 1: START STEP 2: REPEAT FOR I = 1 TO N STEP 3: SET TEMP = ARR[ I ] STEP 4: SET J = I - 1 STEP 5: REPEAT WHILE TEMP <= ARR[ J ] THEN 5.1 SET ARR[ J + 1 ] = ARR[ J ] 5.2 SET J = J - 1 [ END OF INNER LOOP J ] STEP 6: SET ARR[ J + 1 ] = TEMP [ END OF OUTER LOOP ] STEP 7: EXIT I = 1; I / ARR[ I ] / TEMP

0

I = 2; I / ARR[ I ] / TEMP

0

0

1

2

3

TEMP<=ARR[J] J =I - 1 / ARR[ J + 1 ]

1

Condition

If true, Swap

2

3

After Sorting

4

TEMP<=ARR[J] J =I - 1 / ARR[ J + 1 ]

1

Condition

2

If true, Swap

3

After Sorting

4

4

I = 3; I / ARR[ I ] / TEMP

0

TEMP<=ARR[J]

J =I - 1 / ARR[ J + 1 ]

1

I = 4; I / ARR[ I ] / TEMP

0

Condition

If true, Swap

2

3

After Sorting

4

TEMP<=ARR[J] J =I - 1 / ARR[ J + 1 ]

1

Condition

2

If true, Swap

3

After Sorting

4

Data structures part 3 stack, queue, sorting.pdf

STACK – INSERTION- PUSH STACK – DELETION - POP. STEP 1: CHECK STACK “OVERFLOW”. STEP 2: IF TOP < MAX-1 THEN. INCREMENT TOP BY 1.

432KB Sizes 0 Downloads 166 Views

Recommend Documents

Data structures part 1 Singly linked list.pdf
Data structures part 1 Singly linked list.pdf. Data structures part 1 Singly linked list.pdf. Open. Extract. Open with. Sign In. Main menu.

Patient Queue - GitHub
If you are using a Notebook computer with Firefox follow these instructions: .... Claim: this option is selected by a clinician in order to start an exam on a patient. 9 ...

Data And File Structures Lab 3.PDF
... AND FILE STRUCTURES LAB. Time :1 hour Maximum Marks : 50. Note : (i) Answer the following question. (ii) Rest 10 Marks are for Viva - Voce. 1. Write a Program in 'C' Language for the implementation of Bubble Sort. 40. BCSL-033 - Set - 4 1. Page 1

CD - The Inside Story - Part 3 - Data Format
Apr 11, 2017 - Data is recorded on the disc as the presence or absence of "bumps" along ... This period may or may not contain a transition, to restore the DC ...

Data Structures
Under certain circumstances: when your program receives a grade of 10 or. 25, you will be ... social media, classroom papers and homework exercises. Missouri ...

Data Structures
Dr. R. Balasubramanian. Associate Professor. Department of Computer Science and Engineering. Indian Institute of Technology Roorkee. Roorkee 247 667.

Data structures
A data structure where elements can be added or removed at either end but not in the middle: (a) Stack. (b) Queue. (c) Linked list, (d) Deque. 5. Which of the following is a two-way list: (a) Singly linked list. (b) Circular list. (c) Linked list wit

Data Structures
Find the output of the following code int n=32; steps=0; for (int i=1; i

kinetic data structures - Basch.org
Alas, this analysis completely breaks down in the case of line segments, as Lemma 3.1 no longer holds. Instead, we use another potential argument reminiscent of the one used independently by several authors 47, 51, 61] for proving upper bounds on the

kinetic data structures - Basch.org
of robustness), and the software system issue of combining existing kinetic data structures as black boxes .... here is only to give a good prototyping environment.

Verifiable Data Structures - Continusec
Certificate Authorities to issue certificates, mail clients may trust a key server to .... practices we expect a small number of dedicated auditors to perform, rather ...

types of queue in data structure pdf
Loading… Page 1. Whoops! There was a problem loading more pages. types of queue in data structure pdf. types of queue in data structure pdf. Open. Extract.

The queue - GitHub
Input file: A.in. Output file: A.out. Time limit: 1 second. Memory limit: 64 megabytes. There is an interesting queue. Cashier of this queue is not a good one. In fact ...

Data Structures & Algorithms.pdf
Page 2 of 2. Page 2 of 2. Data Structures & Algorithms.pdf. Data Structures & Algorithms.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Data Structures & Algorithms.pdf. Page 1 of 2.

Queue & Autoplay UX Developers
next/prev if queue (if available). ○ play/pause or play/stop. ○ timeline scrubber (if possible). ○ volume icon (iOS only). ○ a link to the content entity page or info.