Lab Manual Signals
Lab Manual Signals
Instructions: All tasks should be completed in the coming Lab Session to get full credit. You must show the output and code of each task to the instructor. Attach separate A4 sheets with manual to complete the assignments if needed. Copying codes and assignments will only lead to embarrassment. So avoid it. Reading: [1] Data Structures and Algorithm Analysis in C by Mark Allen Weiss [2] Data Structures using C and C++ by Langsam, Augenstein, Tenebaum
2. 3. 4. 5. 6.
Creat a New Node NewNode DATA = DATA NewNode Next = TOP TOP = NewNode Exit
#include<conio.h> #include<stdio.h> #include<malloc.h> #include<process.h> //Structure is created a node struct node { int info; struct node *link;//A link to the next node }; //A variable named NODE is been defined for the structure typedef struct node *NODE; //This function is to perform the push operation NODE push(NODE top) { NODE NewNode; int pushed_item; //A new node is created dynamically NewNode = (NODE)malloc(sizeof(struct node));
2/10
printf(\nInput the new value to be pushed on the stack:); scanf(%d,&pushed_item); NewNode->info=pushed_item;//Data is pushed to the stack NewNode->link=top;//Link pointer is set to the next node top=NewNode;//Top pointer is set return(top); }/*End of push()*/ Assignment 1. Write an algorithm for pop() operation of stack using linked list as underlying data structure. 2. Write a C implementation for pop() operation of stack using linked list as underlying data structure. 3. Write a C implementation for display() operation {to display all the elements present in stack}of stack using linked list as underlying data structure. 4. Write a main() program to integrate all above operations of stack in a single application. Hint: Follow the same style adopted in Implementation of stack using Arrays. 5. Explain your understanding about malloc() function used in above implementations.
3/10