Stack making use of the linked list, Data Structure & Algorithms

Assignment Help:

Q. Implement a stack making use of the linked list. Show the PUSH and POP operations both.

Ans.

Stack implemantation using linked list

# include

# include

struct link

{

int info ;

struct link *next;

}   *start;

struct link * push (struct link * rec)

{

struct link *new_rec;

printf ("\n Input the new value for next location of the stack:") ;

new_rec = (struct link *) malloc (size of

(struct link)) ;

scanf ("%d", &new_rec->info) ;

new_rec->next = rec;

rec = new_rec;

return (rec);

}

struct link * pop (struct link * rec)

{

struct link * temp ;

if (rec == NULL)

{

}

else

{

printf ('\n Stack is empty") ;

temp = rec; rec= temp->next;

printf("the popped element %d", temp->.info);

free(temp) ;

return(rec);

}


Related Discussions:- Stack making use of the linked list

Assignment, How do I submit a three page assignment

How do I submit a three page assignment

Asymptotic notation.., important points on asymptotic notation to remember

important points on asymptotic notation to remember

Graph search using iterative deepening, Prove that uniform cost search and ...

Prove that uniform cost search and breadth- first search with constant steps are optimal when used with the Graph-Search algorithm (see Figure). Show a state space with varying ste

Two - way merge sort, Merge sort is also one of the 'divide & conquer' clas...

Merge sort is also one of the 'divide & conquer' classes of algorithms. The fundamental idea in it is to split the list in a number of sublists, sort each of these sublists & merge

Methods of physically storing data in the files, This unit dealt along with...

This unit dealt along with the methods of physically storing data in the files. The terms fields, records & files were described. The organization types were introduced. The sev

Data structure arrays, In this unit, we learned the data structure arrays f...

In this unit, we learned the data structure arrays from the application point of view and representation point of view. Two applications that are representation of a sparse matrix

Rl rotation - avl tree, Example: (Double left rotation while a new node is ...

Example: (Double left rotation while a new node is added into the AVL tree (RL rotation)) Figure: Double left rotation when a new node is inserted into the AVL tree A

Sparse matrix, How sparse matrix stored in the memory of a computer?

How sparse matrix stored in the memory of a computer?

Define ordinary variable, Ordinary variable An ordinary variable of a e...

Ordinary variable An ordinary variable of a easy data type can store a one element only

Dynamic programming., Count Scorecards(30 points) In a tournament, N playe...

Count Scorecards(30 points) In a tournament, N players play against each other exactly once. Each game results in either of the player winning. There are no ties. You have given a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd