Algorithms Assignment | College Homework Help

The attached is the assignment. Consider the problems and design the algorithms that would solve them, Project 2 Building Algorithm Problems [.docx]. You are free to choose between writing pseudocode or drawing flowcharts.

Problem 1:

Read an integer number from the user. If the number is not positive, change its sign. Create the algorithms for the following tasks:

1 Count the digits of the number

2 Count the odd digits of the number

3 Calculate the sum of the digit values of the number

Problem 2:

Using the knowledge acquired in Unit 1, regarding Binary numbers, create an algorithm that reads a 4-bit binary number from the keyboard as a string and then converts it into a decimal number. For example, if the input is 1100, the output should be 12. (Hint: Break the string into substrings and then convert each substring to a value for a single bit. If the bits are b0, b1, b2, and b3, the decimal equivalent is 8b0+ 4b1+ 2b2+ b3.)

Problem 3:

Suppose you attend a party. To be sociable, you will shake hands with everyone else. Write the algorithm that will compute the total number of handshakes that occur. (Hint: Upon arrival, each person shakes hands with everyone who is already there. Use the loop to find the total number of handshakes as each person arrives.)

Problem 4:

Imagine yourself in the middle of Manhattan, where the streets are perpendicular on avenues. You are in a grid of streets, somewhat lost, and you randomly pick one of four directions and walk to the next intersection. Not knowing where you really want to go, you again randomly pick one of the four directions, and so on. After repeating the same movement for a number of times, you may want to know how far you got from the original point.

Represent locations as integer pairs(x,y). Create an algorithm that implements your movement through New York City, over 100 intersections, starting at (0,0) and print the ending location, taking into consideration that each movement, from one intersection to another will be one mile.

Problem 5:

Design an algorithm that, given two strings of characters, tests whether the first string appears as a substring somewhere in the second.

My Master Papers
Calculate your paper price
Pages (550 words)
Approximate price: -