assignment #2

docx

School

Elmhurst College *

*We aren’t endorsed by this school

Course

561

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

3

Uploaded by elsiejossy133

Report
Name: Elsie Onasanya Professor: Prof. Dr. Kamal Dahbur Course: CPSC 2100 Date: October 30, 2023 QUESTION # 1
Draw a circuit diagram corresponding to the following Boolean expression: A'B + (B+C)' QUESTION # 2: Show the behavior of the following circuit with a truth table: A B C A’ B XOR C A’ (B XOR C) 0 0 0 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 0 0 QUESTION # 3: Write a pseudocode algorithm to get three integers from the user and print them in numeric order (smallest to largest). Write "Enter three integer values" Read first, second, third IF (first < second) IF (second < third) Write first, second, third ELSE IF (first < third) Write first, third, second ELSE Write third, first, second ELSE IF (first < third) Write second, first, third ELSE IF (second < third) Write second, third, first ELSE Write third, second, first QUESTION # 4: Using a looping statement, write a top-down design (pseudocode algorithm) for the task of calculating the average of an unknown number of test scores. Step 1: Declare a variable sum to keep track of the sum of the test scores and a variable count to keep track of the number of testscores Step 2: Set the value of sum and count to 0 Step 3: Ask the user to enter the testscore Step 4: Use a looping statement to keep looping until the user enters a negative number Step 5: Inside the loop, add the test score to the sum and increment the count Step 6: After the loop is finished, calculate the average by dividing the sum by the count. Step 7: Output the average to the user
END QUESTION # 5: Using the array shown below, how many comparisons does it take using a binary search to find the following values or determine that the item is not in the list? (You must show work to receive any credit) a) 44 Compare with the middle number 46 (1 st comparison) - Too high, go left. Find the new middle number: 20 (2 nd comparison) - Too low, go right. Find the new middle number: 33 (3 rd comparison)- Too low, go right. Find the new middle number: 44 (4 th comparison) Answer is 4 comparison b) 106 Compare with the middle number 101 (1 st comparison) - Too low, go right. Find the new middle number: 102 (2 nd comparison) - Too low, go right. Find the new middle number: 105 (3 rd comparison) - Too low, go right. Not in the list. Answer is 3 comparison
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