Preview

Data Structures and Algorithm Lab

Good Essays
Open Document
Open Document
3230 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Data Structures and Algorithm Lab
Department of Information Technology

LAB MANUAL

IT2205 – Data Structures and Algorithm Lab

INDEX

1. Array Implementation Of Stack

2. Application Of Stack – Conversion Of Infix To Postfix

3. Implementation Of Linear Queue Using Arrays

4. Array Implementation Of Circular Queue

5. Linked List Implementation Of Stack

6. Singly linked list – Linked list implementation

7. Doubly linked list – Linked list implementation

8. Polynomial Manipulation

9. Tree Traversals

10. Expression Tree

11. Priority Queue Using Heap

12. Hashing Technique

13. Dijkstra’s Algorithm

14. Back tracking algorithm – knap sack problem

Ex. no.: 1

Date :

ARRAY IMPLEMENTATION OF STACK

Aim

To write a C-program to implement stack using array data structure.

And perform the following stack operations

1. POP

2. PUSH

3. PEEP

Algorithm

STEP 1:Start

STEP 2:Initialize stack, will=1,i, num

STEP 3:Add element in stack

PUSH(S,TOP,X)

3.a. [Check overflow condition]

If(TOP>=N) then

Write(“Stack is full”)

3.b. [Insert element]

[Increment TOP]

TOP =1)

post[j++]=pop();

push(2);

break;

case '*':

while(stack[top]>=3)

post[j++]=pop();

push(3);

break;

case '/':

while(stack[top]>=3)

post[j++]=pop();

push(4);

break;

case '^':

while(stack[top]>=4)

post[j++]=pop();

push(5);

break;

case '(':

push(0);

break;

case ')':

while(stack[top]!=0)

post[j++]=pop();

top--;

break;

default:

post[j++]=inf[i];

}

You May Also Find These Documents Helpful

  • Powerful Essays

    CODE FOR THE ABOVE FRAGMENT addi $t6, $zero, 101 # the loop termination value add $t0, $zero, $zero # i = 0 addi $t2, $a0, 0 # ptr to current A[i] addi $t3, $a1, 0 # ptr to current B[i] loop: lw $t4, 0($t3) # load B[i] add $t4, $t4, $s0 # B[i] + c sw $t4, 0($t2) # store in A[i] addi $t0, $t0, 1 # i++ addi $t2, $t2, 4 # ptr to next A[i] addi $t3, $t3, 4 # ptr to next B[i] bne $t0, $t6, loop # if i < 101, goto loop IF ANY QUERIES REGARDING CODE…

    • 107 Words
    • 1 Page
    Powerful Essays
  • Good Essays

    Nt1420 Unit 6

    • 1145 Words
    • 5 Pages

    INSTRUCTIONS: 1. THERE ARE SIX (6) QUESTIONS IN THIS PAPER. 2. ANSWER FIVE (5) QUESTIONS ONLY. Question 1 Arrays are used when storing a large number of values. You are required to create an array named a and answer the following questions regarding array manipulation. a. Write a method fillRandom(int[] a, int min, int max), fill the array a with a random integer value. (Note: Math.random() returns a double in the range of 0.0 and 1.0, therefore it is cast to an integer number, between the minimum and maximum value). [6 marks] b. Write the Bubble sort method to sort array a into descending order. [10 marks] c. In the quicksort, an algorithm an element is chosen from the unsorted list. This element is called the…

    • 1145 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Exercise 1: Review of array-based lists Create a project using the classes in the DocSharing area labeled “User-defined array list." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class provided in the lecture.…

    • 714 Words
    • 3 Pages
    Good Essays
  • Good Essays

    ECET 370 Week 5 Lab 5

    • 650 Words
    • 3 Pages

    Exercise 1: Review of the Lecture Content Create a project using the ArrayList class and the Main class provided in DocSharing. The ArrayList class contains implementations of the first three search methods explained in this week's lecture: sequential, sorted, and binary search. The Main class uses these three methods. These programs test the code discussed in the lecture. Compile the project, run it, and review the code that is given carefully.…

    • 650 Words
    • 3 Pages
    Good Essays
  • Better Essays

    printf(" %d \t\t %d\n\n",stfor->wt,stfor->tt); ttl_wt += stfor->wt; ttl_tt += stfor->tt; temp = np = stfor; del_node(np,1) ; ++i; } else { stfor->bt -= qt; stfor->tt = temp->tt + qt; printf(" %d \t\t %d\n\n",stfor->wt,stfor->tt); np = temp = stfor; del_node(np,2); ins_node(temp); } }while(stfor !=…

    • 401 Words
    • 2 Pages
    Better Essays
  • Good Essays

    1. Flash cards: It is similar to the traditional note cards but in electronic bases. It helps students to recall the terms and definitions of the textbook.…

    • 695 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Cs Programming Chapter 1

    • 2450 Words
    • 10 Pages

    ____ data items may involve organizing or sorting them, checking them for accuracy, or performing calculations with them.…

    • 2450 Words
    • 10 Pages
    Satisfactory Essays
  • Powerful Essays

    MDM4U – Grade 12 Data Management – Exam Unit 1: One Variable Analysis Types of Data Numerical Data Discrete: consists of whole numbers Ie. Number of trucks. Continuous: measured using real numbers Ie, Measuring temperature.…

    • 2372 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    E4.6: The label array_x is the starting address of an array of 100 8bit elements.…

    • 900 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Concept Programing

    • 443 Words
    • 3 Pages

    3. (15%) Design a state diagram to recognize one form of the comments of the C-based programming languages,…

    • 443 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    1. What is inventory in business processes? Provide two different production strategies on how inventory is managed. Discuss the advantage and disadvantage of inventory in business processes.…

    • 486 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Program Evaluation Fast

    • 4469 Words
    • 18 Pages

    efficiency and effectiveness of the FAST program is constrained by a number of challenges that…

    • 4469 Words
    • 18 Pages
    Powerful Essays
  • Powerful Essays

    Cen 254 Data Structure

    • 924 Words
    • 4 Pages

    keys 30, 40, 24, 58, 48, 26, 11, 13 (in this order). Draw the tree after each…

    • 924 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    Computer Concepts Exam 1

    • 951 Words
    • 4 Pages

    According to the textbook authors, what is another name for the rows in a database table? Records…

    • 951 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    CS 220 – Programming w/ Data Structures: You have missed one assignment and one quiz. Your instructor has extended your assignment due date to this Sunday, April 10. Your instructor has also let you to take your Quiz # 2 during his office hours during this week. Let me know if you need additional support to study for this quiz. Your grade to date in this class is 30.2/37 81.62% B.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays