#1
| |||
| |||
![]()
Will you please provide me Lecture Notes for master of computer application course??
|
#2
| ||||
| ||||
![]()
here I am giving you MCA-Lecture Notes in word file attached with it so you can get it easily.. some content is given below : Ex. No : 2 Create a Stack and do the basic operations using Arrays Date : Algorithm: 1. Start 2. Declare an one dimensional array variable 3. Using Switch case statement select one appropriate operation a. PUSH: i. Read an element ii. Store it at the top of the stack iii. Increment the TOS b. POP i. Read the element from the top of the stack ii. Display it iii. Decrement the TOS c. PEEK i. Read the element from the top of the stack ii. Display it 4. Stop Logical Description The program implements the Stack using one dimensional array. Initially an array variable is declared, and variable TOS is to point the top of the stack is also declared. PUSH operation is done by reading an element from the user and storing it at TOS position. POP operation retrieves the value at TOS and removes the element; TOS now points the next element. PEEK operation retrieves the element but it is not deleted from the stack. Program Code /*Stack Using Arrays*/ #include #include #define SIZE 4 int a[SIZE],top=0,ch=1,i,n; void display(); void create(); void push(); void pop(); 1. Represent the given sparse matrix using one dimensional array and linked list. 2. Create a Stack and do the following operations using arrays and linked lists (i)Push (ii) Pop (iii) Peep 3. Create a Queue and do the following operations using arrays and linked lists (i)Add (ii) Remove 4. Implement the operations on singly linked list, doubly linked list and circular linked list. 5. Create a binary search tree and do the following traversals (i)In-order (ii) Pre order (iii) Post order 6. Implement the following operations on a binary search tree. (i) Insert a node (ii) Delete a node 7. Sort the given list of numbers using heap and quick sort. 8. Perform the following operations in a given graph (i) Depth first search (ii) Breadth first search 9. Find the shortest path in a given graph using Dijkstra algorithm Algorithm: 1. Start 2. Declare an one dimensional array variable 3. Using Switch case statement select one appropriate operation a. PUSH: i. Read an element ii. Store it at the top of the stack iii. Increment the TOS b. POP i. Read the element from the top of the stack ii. Display it iii. Decrement the TOS c. PEEK i. Read the element from the top of the stack ii. Display it 4. Stop Logical Description The program implements the Stack using one dimensional array. Initially an array variable is declared, and variable TOS is to point the top of the stack is also declared. PUSH operation is done by reading an element from the user and storing it at TOS position. POP operation retrieves the value at TOS and removes the element; TOS now points the next element. PEEK operation retrieves the element but it is not deleted from the stack. Program Code /*Stack Using Arrays*/ #include #include #define SIZE 4 int a[SIZE],top=0,ch=1,i,n; void display(); void create(); void push(); void pop(); void peek(); void main() { clrscr(); printf("\n\t\tStack Using Arrays"); printf("\n\t\t------------------"); printf("\n\t\t 1.Create"); printf("\n\t\t 2.Push"); printf("\n\t\t 3.Pop"); printf("\n\t\t 4.Peek"); printf("\n\t\t 5.Exit\n"); do { printf("\t\tEnter Your Choice :"); scanf("%d",&ch); switch(ch) { case 1: create();break; case 2: push();break; case 3: pop();break; case 4: peek();break; default: printf("\t\tExit"); break; } }while(ch!=5); getch(); } void create() { if(top==0) { printf("\t\tNumber of Element:"); scanf("%d",&n); if(n>SIZE) printf("\t\tSize of Stack is Large\n"); else { printf("\t\tPushing Element :"); for(i=1;i<=n;i++) scanf("%d",&a[i]); top=n; display(); } } else { printf("\tStack Already Exists"); } } void push() { if(top==SIZE) printf("\t\tStack Overflow\n"); else { printf("\t\tPushing Element :"); scanf("%d",&a[++top]); display(); } } void pop() { if(top==0) printf("\t\tStack Underflow\n"); else { printf("\t\tPop Element :%d\n",a[top--]); display(); } } void display() { if(top==0) printf("\t\tStack is Empty"); else { printf("\t\tStack Contains :"); for(i=top;i>=1;i--) printf("%d ",a[i]); } printf("\n"); } void peek() { if(top==0) printf("\t\tStack Empty\n"); else printf("\t\tTop Element is %d\n",a[top]); } Expected Output IMPLEMENTATION OF STACK USING ARRAYS Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 1 Enter the element to be pushed into the stack: 12 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 1 Enter the element to be pushed into the stack: 15 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 1 Enter the element to be pushed into the stack: 34 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 4 The elements in the stack are: 12 15 34 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 2 The Popped value is: 34 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 4 The elements in the stack are: 12 15 Choose the option 1. Push 2. Pop 3. Peek 4. Display 5. Exit Enter your option: 3 The Popped value is: 15
__________________ Answered By StudyChaCha Member |