hw2

docx

School

Bluegrass Community and Technical College *

*We aren’t endorsed by this school

Course

244

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by MegaClover13750

Report
1. a. Describe each of the following tkinter widgets: i. Label A Label widget in tkinter is used to display text or images on a GUI window. ii. Entry An Entry widget in tkinter is used to create a single line input field in a GUI. iii. Button A Button widget is used to create clickable buttons that perform an action in a GUI. iv. Frame A Frame widget is used to organize other widgets in a GUI. b. What does the tkinter module’s mainloop do? The mainloop in the tkinter module keeps your GUI program responsive so that it doesn’t immediately end. 2. Consider the following recursive function: a. Considering recursion, what is the if part called? What is the else part called? The if part is called the base case, and the else part is called recursive case. b. Explain the purpose of this p function? The purpose of the p function is to calculate what happens when you raise the integer m to power of the integer n . 3. Which uses up more time and computer memory space, recursion or iteration using a while/for loop? Explain your answer. The performance depends on the problem and implementation, however, recursion usually uses more memory to maintain its calls. 4. Give the output of the following pieces of Python code? a. The output is: 4 3 b. The output is: 4 3 2 5. Use Bubble sort to sort the list in the array below in ascending order. For each pass through the array you should rewrite the elements of the array writing the numbers in their new positions. Please one rewrite per pass. Pass 1: 3 43 68 55 72 36 89 117 Pass 2: 3 43 55 68 36 72 89 117 Pass 3: 3 43 55 36 68 72 89 117 Pass 4: 3 43 36 55 68 72 89 117 Pass 5: 3 36 43 55 68 72 89 117 Pass 6: 3 36 43 55 68 72 89 117 Pass 7: 3 36 43 55 68 72 89 117
6. Use Merge sort to sort the list in the array below in ascending order. For each pass through the array you should rewrite the elements of the array writing the numbers in their new positions. Please one rewrite per pass. Pass 1: 1 7 2 8 3 4 5 6 Pass 2: 1 2 7 8 3 4 5 6 Pass 3: 1 2 3 4 5 6 7 8
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help