/* C program to implement stacks using arrays */ #define MAX 10 void push(); void pop(); void display(); int a[MAX],top=-1; main() { int ch; clrscr(); while(1) { printf("\n 1 push an element \t 2 pop \t 3 display \t 4 exit"); printf("\n\n enter your choice"); scanf("%d",&ch); switch(ch) { case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: exit(0); break; default: printf("\n enter a valid choice"); break; } } } void push() { int ele; if(top==MAX-1) printf("\n stack is full"); else { top=top+1; printf("\n enter an element to be inserted"); scanf("%d",&ele); a[top]=ele; }

} void pop() { if(top==-1) printf("\n stack is empty"); else { printf("\n removed element is %d",a[top]); top--; } } void display() { int i; if(top==-1) printf("\n stack is empty"); else { for(i=0;i<=top;i++) printf("\t %d",a[i]); } } OUTPUT:

/* C program to implement queues using arrays */ #define MAX 5 void enqueue(); void delete(); void display(); int a[MAX],front=-1,rear=-1; main() { int ch; clrscr(); while(1) { printf("\n 1 enqueue \t 2 dequeue \t 3display \t 4 exit"); printf("\n\n enter your choice"); scanf("%d",&ch); switch(ch) { case 1: enqueue(); break; case 2: delete(); break; case 3: display(); break; case 4: exit(0); break; default: printf("\n enter the correct choice"); break; } } } void enqueue() { int ele; if(rear==MAX-1) { printf("\n queue is full"); } else { if(front==-1) front=0; printf("\n enter the element to be inserted");

scanf("%d",&ele); rear++; a[rear]=ele; } } void delete() { if(front==-1||front>rear) { printf("\n queue is empty"); return; } else printf("\n removed element is %d",a[front]); front++; } void display() { int i; if(front==-1) printf("\n queue is empty"); else { for(i=front;i<=rear;i++) { printf("\n %d",a[i]); } } }

OUTPUT

T.A.K.R

ds stacks and queues using arrays (1).pdf

ds stacks and queues using arrays (1).pdf. ds stacks and queues using arrays (1).pdf. Open. Extract. Open with. Sign In. Main menu.

120KB Sizes 2 Downloads 239 Views

Recommend Documents

Stacks
Stacks. Page 2. LIFO push pop. Page 3. typedef struct. { char* strings[CAPACITY]; int size;. } stack;. {. Page 4. push TODOs: size < CAPACITY? store element at.

Queues
typedef struct. { int head; char* strings[CAPACITY]; int size;. } queue;. {. Page 4. Enqueue TODOs: [0]. [1]. [2]. [3]. [4]. [5] head size < CAPACITY? store at tail.

QUEUES WITH BEAKDOWNS AND CUSTOMER ...
breakdowns and customer discouragement. Each of the customers present in the system at the time of a breakdown may become discouraged and leave with a constant probability, independently of other customers. The system alternates between working and r

SYMMETRIC QUOTIENT STACKS AND HEISENBERG ...
arXiv:1403.7027, 2014. [FT11] B. L. Feigin and A. I. Tsymbaliuk. Equivariant K-theory of Hilbert schemes via shuffle algebra. Kyoto J. Math., 51(4):831–854, 2011 ...

Synthesis of Antenna Arrays Using Artificial Bee Colony ...
possible solution values. The parameters are ... narrowing the solution space based on results from ..... D. W. Boeringer and D. H. Werner, “Particle.

Math Stacks Math Stacks Use Case Diagram
Create a set of Problems. Practice. Problems. Randomly generated. Quizzes. Teacher made Quizzes. View Personal. Scores. View Student. Scores. Create an. Account. Teacher. Student. >. Math Stacks. Math Stacks Use. Case Diagram.

High-throughput gene silencing using cell arrays - Nature
Cell array as a functional genomics tool ... statistical analysis of the data acquired by microscope or ..... Brummelkamp TR, Bernards R and Agami R. (2002).

Arrays
Creating an Array. 65 87 30. 1. 0. 2. name[];. Example: int temperature[3]; temperature[0] = 65; temperature[1] = 87; temperature[2] = 30;. OR int temperature[] = { 65, 87, 30 }; ... Where's the bug? string class[3] = { "Sam", "Jess", "Kim" }; for (

Co-Arrays and Multi-Cores
Nov 16, 2009 - A single program is replicated a fixed number of times. ▷ num images() returns the number of images at run-time. ▷ this image() returns the ...

Balanced nested designs and balanced arrays - ScienceDirect.com
Balanced nested designs are closely related to other combinatorial structures such as balanced arrays and balanced n-ary designs. In particular, the existence of symmetric balanced nested de- signs is equivalent to the existence of some balanced arra

MIXED MOTIVES AND QUOTIENT STACKS: ABELIAN ...
Cat∞: the ∞-category of small ∞-categories in a fixed Grothendieck universe U (cf. ..... Let Z be the set of isomorphism classes of all (finite-dimensional) irre-.

Gingerbread and Candy Arrays - Intermediate.pdf
Page 2 of 14. Credits: www.kevinandamanda.com/fonts/freescrapbookfonts. www.scrappindoodles.com. www.letteringdelights.com. digiscrapkits.com. frompond.blogspot.com. printcandee.com. http://the3amteacher.blogspot.com/. www.kpmdoodles.com. http:rowdyi

lEiwwww.kZrk ds Zrk ds .kZrk ds Zrk ds------ 18 fnu -
dh /kkj.kkvksa dk vkSj vH;kl djsaxs mu Lo:iksa esa fLFkr gksus dk---- vkse 'kkfUr .... nsdj eq>s fo'o ifjorZu dh bruh cM+h ftEesokjh dk rkt iguk;k gS--------.

Strategic Experimentation in Queues
Dec 13, 2017 - from Deutsche Bank through IAS Princeton. We thank a co-editor and ..... integer part of x. 11 Observe that ψk = E(δ˜τk ), where the random variable ˜τk is the arrival time of the kth service event, for k ∈ N. ...... ion, Custo

Strategic Experimentation in Queues
Sep 5, 2016 - they arrive; they, therefore, solve a strategic experimentation problem when deciding how long to wait to learn about the probability of service.

EXTENSIONS OF PICARD STACKS AND THEIR ...
the site S: all complexes that we consider in this paper are cochain complexes. .... category (i.e. it is possible to make the sum of two objects of P(U) and this sum.

EXTENSIONS OF PICARD 2-STACKS AND THE ...
(2) Let F : A → B be an additive 2-functor between Picard 2-stacks and let f = (qf ,M,pf ) be the fraction of T[−2,0](S) corresponding to F via (1.1). We have Ker(F) = 2st(τ≤0(MC(pf )[−1])) and Coker(F) = 2st(τ≥−2(MC(pf ))) . 3. The 3-c

Leverage Stacks and the Financial System - School of Economics ...
Jun 17, 2011 - Is a financial system without netting – where ... than a financial system with netting? ... as security, because she does not know enough to judge ...

The Performance Cost of Shadow Stacks and ... - Research at Google
for profit or commercial advantage and that copies bear this notice and the full cita- tion on the first page. ..... There are two main disadvantages compared to a tradi- .... it may be related to forking and our (mis-)use of %gs:108 to store the ...

Symmetric quotient stacks and Heisenberg actions
derived categories of the symmetric quotient stacks of an arbitrary smooth ...... assume that the objects α and β have complete support, i.e. α, β ∈ Dc(X), which ...

Wait-free queues with multiple enqueuers and dequeuers
Technion, Israel [email protected]. Erez Petrank ... To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific ...

Perspectives on Queues: Social Justice and the ...
For the great majority of queueing system “customers the actual and/or ... disciplined” multi-line situation with high chance of ..... coming telephone call. Next to ...