Algorithm & Data Structures, Cheat Sheet of Data Structures and Algorithms

This document is a complete breakdown for students facing challenges under Algorithm & Data Structures

Typology: Cheat Sheet

2024/2025

Uploaded on 01/06/2026

nfor-divine
nfor-divine 🇺🇸

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ALGORITHMANDDATASTRUCTURE1
Lecturer:MUGHEGODLOVE
Exercise1
WriteanalgorithmthatdisplaysthemessageHello.
Exercise2
Writeanalgorithmthatallowstheusertoentertwonumbersanddisplaystheirproduct.
Exercise3
WriteanalgorithmthatexchangesthevaluesoftwointegersAandBenteredbytheuser,then
displaysthemaftertheswap.
Exercise4
Writeanalgorithmthatdetermineswhetheranintegerenteredbytheuserisevenorodd.
Exercise5
Writeanalgorithmthatdisplaysthelargestofthreeintegersenteredbytheuser.
Exercise6
Writeanalgorithmthatevaluatesagradeenteredbytheuser.Ifthegradeisgreaterthan10,display
Passed,otherwisedisplayFailed.(Note:thegradeisbetween0and20.)
Exercise7
Writeanalgorithmthataskstheusertoentertwonumbersmandnandthentellswhetherthe
productofthetwonumbersispositive,negative,orzero.
Exercise8
Writeanalgorithmthatcalculatestheabsolutevalueofanintegerenteredbytheuser.
Exercise9
Writeanalgorithmthatcalculatestheaverageofthreeintegersenteredbytheuser.
Exercise10
Ashopgivesa15%discountforpurchasesover200units.Writeanalgorithmthatreadsthetotal
price(beforetax),appliesthediscountifapplicable,andadds20%VAT,thendisplaysthefinal
total.
Exercise11
Aphotocopycentercharges:0.25percopyforthefirst10copies,0.20percopyforthenext20
copies,and0.10percopyforanycopybeyondthat.Writeanalgorithmthatreadsthenumberof
copiesmadeanddisplaysthetotalcost.
Exercise12
pf3
pf4

Partial preview of the text

Download Algorithm & Data Structures and more Cheat Sheet Data Structures and Algorithms in PDF only on Docsity!

ALGORITHM AND DATA STRUCTURE Lecturer: MUGHE GODLOVE Exercise 1 Write an algorithm that displays the message Hello. Exercise 2 Write an algorithm that allows the user to enter two numbers and Exercise 3 Write an algorithm that exchanges the values of two integers A ar displays them after the swap. Exercise 4 Write an algorithm that determines whether an integer entered by Exercise 5 Write an algorithm that displays the largest of three integers ente Exercise 6 Write an algorithm that evaluates a grade entered by the user. lf Passed , otherwise display Failed. (Note: the grade is between Exercise 7 Write an algorithm that asks the user to enter two numbers m and product of the two numbers is positive, negative, or zero. Exercise 8 Write an algorithm that calculates the absolute value of an intege Exercise 9 Write an algorithm that calculates the average of three integers e Exercise 10 A shop gives a 15% discount for purchases over 200 units. Write price (before tax), applies the discount if applicable, and adds 2( total. Exercise 11 A photocopy center charges: 0.25 per copy for the first 10 copies copies, and 0.10 per copy for any copy beyond that. Write an algc copies made and displays the total cost. Exercise 12 Write an algorithm that - Poussin for ages 6 7 - Pupille for ages 8 9 reads a child s age and displays his or he - Minime for ages 10 11 - Cadet for age 12 and above. Exercise 13 Write an algorithm that February, etc.). Exercise 14 Write an algorithm that Exercise 15 Write an algorithm that Exercise 16 Write an algorithm that using a while loop. Exercise 17 Write an algorithm that Exercise 18 Write an algorithm that Exercise 19 Write an algorithm that using a for loop. Exercise 20 Write an algorithm that Exercise 21 Write an algorithm that for loop. Exercise 22 Write an algorithm that Exercise 23 Write an algorithm that Exercise 24 displays the month name according to the displays Good Evening ten times using a calculates the sum S 1+2+3+ & +410 calculates the sum S 1+2+3+8& +N, displays Hello ten times using a for loor calculates the sum S 1+2+3+ & +410 calculates the sum S 1+2+3+8& +N, displays the multiplication table of 5 usin displays the multiplication table of any nu displays Hello ten times using a do-whil. calculates the sum S =1+2+3 + & + 10 Write an algorithm that calculates the number of digits in an inte, Example: N = 10843! number of digits = 5. Exercise 36 Write an algorithm that reverses the digits of an integer N entere ! result = 27653. Exercise 37 Write an algorithm that displays the following pattern for a given 1110111 1100011 1000001 0000000 Exercise 38 Write an algorithm that allows the user to enter 10 integers into ~ elements are even and how many are odd. Exercise 39 Write an algorithm that checks whether a given integer N is a prir Exercise 40 Write an algorithm that allows the user to enter 10 integers into ~ numbers in array T1 and the odd numbers in array T2, and display