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

Asymptotic analysis, Asymptotic Analysis Asymptotic analysis is dependi...

Asymptotic Analysis Asymptotic analysis is depending on the idea that as the problem size grows, the complexity can be defined as a simple proportionality to some known functio

Exlain double linked list, Double Linked List In a doubly linked list, ...

Double Linked List In a doubly linked list, also known as 2 way lists, each node is separated into 3 parts. The first part is called last pointer field. It has the address of t

If else, design algorithm and flow chart that computes the absolute differe...

design algorithm and flow chart that computes the absolute difference of two values x and y

Operating system, discuss the operating system under the following: MONOLIT...

discuss the operating system under the following: MONOLITHIC SYSTEM,LAYER SYSTEM AND VIRTUAL MACHINES

Multiple queue, How to create multiple queue on single array?

How to create multiple queue on single array?

Surrounding of sub division method, Surrounding of sub division method ...

Surrounding of sub division method A polygon surrounds a viewport if it completely encloses or covers the viewport. This happens if none of its sides cuts any edge of the viewp

Enumerate about the carrier set members, Enumerate about the carrier set me...

Enumerate about the carrier set members Ruby is written in C, so carrier set members (which is, individual symbols) are implemented as fixed-size arrays of characters (which is

Primitive data structure, Primitive Data Structure These are the basic ...

Primitive Data Structure These are the basic structure and are directly operated upon by the machine instructions. These in general have dissimilar representations on different

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