Você está na página 1de 10

DATA STRUCTURES & PROGRAMMING

DATA STRUCTURES
Experiment No: 6 Date 1.Aim: Find expected number of passes, comparisons and exchanges for bubble sort when n 1! and compare them with actual number of those operations when the gi"en se#uence is as follows:$ %,6,&,',(,),*,1!,1,1+,! !.Algorithm:$ ,tep 1: ,tart ,tep !: Declare -ariables, a,n,i,.,cl,b,ax1,ax!,ax' ,tep ': /lear ,creen ,tep &: 0rinting the heading as 12340345 in the centre of the screen b6 starting the print from center of the screen. ,tep *: 7etting 8nput as number of elements ,tep 6: 9ead -alues for arra6 elements ,tep (: 7etting -alues for arra6 elements ,tep %: Execute the bubble sort function ,tep ): 0rint the results ,ub Function ,tep 1+: Declare -ariables i,.,:,temp,l,abc1,def1. ,tep 11: 0rint unsorted data ,tep 1!: ,tore the 1st element "alue to 4emp -ariable ,tep 1': ,tore the !nd element "alue to 1st element position ,tep 1&: ,tore the 4emp -ariable "alue to !nd element position ,tep 1*: 9epeat the step 11,1!,1' until .;n$1 ,tep 16: 0rint the arra6 elements until :;n ,tep 1(: 0rint No of 0asses, No of /omparison, Number of Exchange ,tep 1%: ,top :

DATA STRUCTURES:Experiment No: % Date: 1.Aim: Define a node with structure of data < lin: and 9ead n elements, allocate them into n nodes in a lin:ed list: a= 8nsert a node after a gi"en node. b= Delete a node containing some elements. c= ,earch a node for a gi"en elements. !.Algorithm: ,tep 1: ,tart ,tep !: Declare -ariables emplo6ee numbers, emplo6ee name and Designation ,tep ': Declaration of new node ,tep &: Assigning of new node ,tep *: 8f new node is null, print error message as allocation failed, else insert new element to node ,tep 6: During inserting after node, 8f there is no node, print the node as first ,else print node as re#uired. ,tep (: During inserting after node, 8f there is a gi"en node is not a"ailable, print error message as node is not found in the list, else insert the node as re#uired. ,tep %: 0rint node emp no ,tep ): 0rint node emp name ,tep 1+: 0rint node designation ,tep 11: 8f the gi"en node is found, node will be deleted, else it will print Error message as emplo6ee number not found.

,tep 1!: ,earch the gi"en node in the lin:ed list, if found, it will displa6 the node details, else it will print error message as Emplo6ee number not found. ,tep 1': 0rint the all nodes in lin:ed list ,tep 1&: /lear screen. ,tep 1*: Displa6 the menu for selection. ,tep 16: Declare "ariable choice. ,tep 1(: 9ead the "alues for choice "ariable. ,tep 1%: >ased on choice input, function will execute. ,tep 1): Declare "ariables name, desig, choice, eno, i, num,loc ,tep !+: 9ead the "alues for the si?e of elements. ,tep !1: 9ead the input for node element "alues until i;num ,tep !!: Execution of choice "ariable. ,tep !': ,top

PROGRAMMING:Experiment No: 11 Date 1.Aim: De"elop a Function on / that splits a list into two other so that the entries that were in odd$numbered positions are now in one list @ 8n the same relati"e order as before= and those from e"en$numbered position are in another new list. !.Algorithm: ,tep 1: ,tart ,tep !: Declare -ariables i. ,tep ': 8f gi"en option is odd, eo 525 will execute. ,tep &: Find mod "alue for the arra6 element, if result is not e#ual to + and i is greater than +, print number as odd. 9epeat the step until i;x num. ,tep *: 8f gi"en option is e"en, eo 5E5 will execute ,tep 6: Find mod "alue for the arra6 element, if result is e#ual to + and i is greater than +, print number as e"en. 9epeat the step until i;x num. ,tep (: Declare "ariables arra6, i, num ,tep %: 9ead arra6 si?e. ,tep ): 9ead arra6 elements "alues. ,tep 1+: 0rint e"en numbers A E. ,tep 11: 0rint odd numbers A 2. ,tep 1!: 8f i is lesser than +, then print error message as in"alid data. ,tep 1': ,top. :

PROGRAMMING:Experiment No: 1* Date: 1.Aim: Brite a 1/5 program to print the da6 for an input of date, month and 6ear. !.Algorithm: ,tep 1: ,tart. ,tep !: Declare -ariables d, m, 6, i, n ,tep ': /lear screen ,tep &: 9ead input "alues date, month< 6ear ,tep *: 8f month !, Find the 6ear is leap 6ear on not. 8f 6ear is not leap 6ear and date greater than !%, print error message as in"alid date. 8f 6ear is leap 6ear and date greater than !), print error message as in"alid date. Else if month 1,',*,(,%,1+,1! < date is greater than '1, print error message as in"alid date in month. 4he maximum "alue is '1. 7o to step &. Else if month &,6,),11 < date is greater than '+, print error message as 8n"alid date in month. 4he maximum "alue is '+, 7o to step &. Else if date is greater than '1, print error message as enter "alid date. 7o to step &. ,tep 6: 8f date or month is less than 1, displa6 error message as enter positi"e "alid data. 7o to step &.

,tep (: Else switch case with month "ariable. Conth 1 < 1+ then r1 "ariable dateD! Conth ! < ' <11 then r1 "ariable Conth & < ( then r1 "ariable Conth ) < 1! then r1 "ariable date Conth * then r1 "ariable dateD' Conth 6 then r1 "ariable dateD6 Conth % then r1 "ariable dateD& 8f no case "alue found then print error message as 8n"alid data. ,tep %: Find the leap 6ear !++' < below or greater than!++' < execute the function. ,tep ): ,witch case with gi"en da6 "ariable. ,tep 1+: 0rint case 1+5 4he da6 is ,unda6 0rint case 115 4he da6 is Conda6. 0rint case 1!5 4he da6 is 4uesda6 0rint case 1'5 4he da6 is Bednesda6 0rint case 1&5 4he da6 is 4hursda6 0rint case 1*5 4he da6 is Frida6 0rint case 165 4he da6 is ,aturda6 ,tep 11: ,top dateD* dateD1

03E,E AND D8784AE /89/384, Exp No.1 A ,6nchronons counter 2b.ecti"e:$ 4o design a & bit s6nchronous counter Function:$ i= ,6nchronous counter is the most used and reliable counter design. ii= ,6nchronous counter ensures that all output bits changed simultaneousl6 at the edge of a cloc: signal and holds that output until the next cloc: signal. iii= Eow propagation dela6 than as6nchronous counter . i"= 4he set reset options become effecti"e with cloc: edge signal, so the output do not change suddenl6 in mid clo: period. "= ,etFreset options allows to clear the count data to start new counting session. "i= /arr6 in and carr6 out allows % bit or higher bits copunters b6 cascading. ,6nchronous counter & bit with GH Flip Flops:$ 8n ,6nchronous counter, the external cloc: signal is connected to the cloc: input of e"er6 indi"idual flipflop with in the counter so that all of the flipflops are cloc:ed together simultaneousl6 @in paraller= at the same time gi"ing a fixed time relationship@or= changes in the output occur in I,6nchroni?ationJ with the cloc: signal. 4his results in all indi"idual output bits changing state at exactl6 the same time in response to the common cloc: signal with no nipple effect and therefore, no propagation dela6. 8t seen that external cloc: pulses @pulses to be counted= are fed directl6 to each G$H flip$flop in the counter chain and that both G<H inputs are all tied together in toggle mode, but onl6 in the first Flip$Flop, FlipFlop a @/,>= are the6 connected K87K logic 8 allowing the flipflop to toggle on e"er6 cloc: pulse. 4hen the ,6nchronous counter follows a predetermined se#uence of states in response to the common cloc: signal ad"ancing one state for each pulse. 4he G<H inputs of flipflop > are connected to the output L of flipflop A, but G<H inputs of flipflops /<D are dri"en from AND gates which also supplied with signals from the input < output of the pre"ious stage. 8f enable each G$H flipflop to toggle based on whether or not all preceding flipflop output@L= are IK87KJ < obtain the same counting se#uence as with the as6nchronous circuit but without the ripple effect, since each flipflop in this circuit will be cloc:ed at exactl6 the sme time. As there is no propagation dela6 in s6nchronous counters because all the counters stages are triggered in parallel the maximum operating

fre#uenc6 of this t6pe of counter is much higher than that of a similar s6nchronous counter.

4934K 4A>EE:

0resent ,tate ++++ +++1 ++1+ ++11 +1++ +1+1 +11+ +111 1+++ 1++1 1+1+ 1+11 11++ 11+1 111+ 1111

Next ,tate +++1 ++1+ ++11 +1++ +1+1 +11+ +111 1+++ 1++1 1+1+ 1+11 11++ 11+1 111+ 1111 ++++

G' + + + + + + + 1 M M M M M M M M

H' M M M M M M M M + + + + + + + 1

G! + + + 1 M M M M + + + 1 M M M M

H! M M M M + + + 1 M M M M + + + 1

G1 + 1 M M + 1 M M + 1 M M + 1 M M

H1 M M + 1 M M + 1 M M + 1 M M + 1

G+ 1 M 1 M 1 M 1 M 1 M 1 M 1 M 1 M

H+ M 1 M 1 M 1 M 1 M 1 M 1 M 1 M 1

4his & bit s6nchronous counter counts se#uentiall6 on e"er6 cloc: pulse the resulting 2utputs count upwards from + @I++++J= to 1* @I1111J=. 4hen to ,ummarise 4he6 are called s6nchronous counters because the cloc: input of the flip flops are cloc:ed with the same cloc: signal. ,6nchronous counters are also called parallel counters as the cloc: is fed in parallel to all flip flops.

4he memor6 section :eeps frac: of the present state. Ad"antages of ,6nchronous counters:$ ,6nchronous counters are easier to design. Bith all cloc: inputs wited together there is no inherent propagation dela6. 2"erall faster operation ma6 achie"ed compared to As6nchronous counters.

Você também pode gostar