Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Lab 8 assignment.docx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 5 Anzeige

Weitere Verwandte Inhalte

Anzeige

Lab 8 assignment.docx

  1. 1. Lab 8 assignment DEPARTMENT OF COMPUTER ENGINEERING,UET LAHORE. Session 2022-2026 Submitted by: Abdulrehman bhatti 2022-CE-47 Submitted to: Ma’am Darakhshan Abdul-ghafar
  2. 2. Lab Task1: a) Why does odd numbered items need two base cases? Ans) because if either the first item of list is empty then execute first base case or if all the items in list empty except first one then execute base2 case otherwise execute the whole list. That’s why, there 2 base cases are used. b) Write a version of even numbered items that calls itself recursively instead of using odd numbered items. c) Can you write a version of odd numbered items that uses (the original) even numbered items instead of calling itself recursively? That structure (A calls B, B calls A) is called mutual recursion.
  3. 3. Lab Task2: Make a squares block that takes a list of numbers as input, and reports a list of the squares of the numbers. Lab Task3: Make an exaggerate block that takes a sentence as input.
  4. 4. Lab Task4: 4. Write a block ends-e that takes a list of words as input, and reports a list of those words from the input whose last letter is e . Lab Task5: 5. Write a block numbers that takes a list of mixed words and numbers as input, and reports a list of just the numbers from the input list.
  5. 5. Lab Task6: Sorting a List: Merging a) Now that we've solved the split-in-half problem, the remaining challenge is to merge two sorted lists into a single in-order list. b) And here's the sort block that uses these pieces:

×