Question

Question 2: [30 Marks] Considering the concepts of algorithms, answer the following questions: a) Write pseudocode for a progPlease answer both A and B.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)Pseudocode :Average of marks of 6 subjects stored in array marks

Function Main
Declare Integer Array marks[6]
Declare Integer i, sum, average
  
Assign sum = 0
Output "Enter 6 marks :"
For i = 0 to 5
Input marks[i]
Assign sum = sum+marks[i]
End
Assign average = sum/6
Output "Average of marks of 6 subjects : "&average
End

b) flowchart : printing 3 characters in ascending order

Main String char1, char2, char3 옷 False True (char1<char2) False True False True char2<char3 char2<char3 False True False Tru

Add a comment
Know the answer?
Add Answer to:
Please answer both A and B. Question 2: [30 Marks] Considering the concepts of algorithms, answer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please answer this in python pseudocode. It's an algorithm question. 1. [10 marks] Consider the function...

    Please answer this in python pseudocode. It's an algorithm question. 1. [10 marks] Consider the function SumKSmallest(A[0..n – 1), k) that returns the sum of the k smallest elements in an unsorted integer array A of size n. For example, given the array A=[6,-6,3,2,1,2,0,4,3,5] and k=3, the function should return -5. a. [3 marks) Write an algorithm in pseudocode for SumKSmallest using the brute force paradigm. Indicate and justify (within a few sentences) the time complexity of your algorithm. b....

  • Question 2 (10 marks) Linked Data Structures: Answer both parts below. Part A (5 marks): The...

    Question 2 (10 marks) Linked Data Structures: Answer both parts below. Part A (5 marks): The in-order traversal of a binary tree processes the nodes in the order ABCD. The post-order traversal of the same binary tree processes the nodes in the order ACDB. Draw the tree below. Part B (5 marks) Inserting one element at a time, what is the best case time complexity to add n elements to an initially empty linked list so that the stored values...

  • Please and thank you 2) (5 pts) Arrays & Vectors: write a program which prompts the...

    Please and thank you 2) (5 pts) Arrays & Vectors: write a program which prompts the user to enter numbers (terminated with a non-numeric), reads them simultaneously into an array of doubles and into a vector of doubles, then prints A) the array elements in the original order B) the vector elements in reverse order C) the average of the vector elements D) the largest of the vector elements Example program output, user input shown underlined Enter a list of...

  • the question from the course COMP 4040 that Analysis of Algorithms if you want to answer it by code please use C or C++...

    the question from the course COMP 4040 that Analysis of Algorithms if you want to answer it by code please use C or C++ 5. Algorithm Design (20 points) Input: array A contains n distinct numbers from 1 to n, in arbitrary order. Output: number of inversions (defined as the number of pair(i, j) of array indices with i < j and A[i] > Aj]) (a) (5 points) What array with elements from the set {1, 2, ..., n) has...

  • I need to be done question 2 , but im posting both questions as you have...

    I need to be done question 2 , but im posting both questions as you have to get the information from question 1 in order to answer question 2 . Stars indicate difficulty: *Should be straightforward based on lecture and tutorial material. *Should be more challenging but still based on lecture and tutorial material. **Might require some further thought or extra research beyond lecture and tutorial material. 1. [8 marks] You have been given a file with two columns: a...

  • Question No.1 [CLO 1][7 marks] 1. Consider the following pseudocode: Algorithm IterativeFunction (a, b) // a...

    Question No.1 [CLO 1][7 marks] 1. Consider the following pseudocode: Algorithm IterativeFunction (a, b) // a and b are integers while (a>0) B- a/2 A a-2 end while return b; i. What is the time complexity of the IterativeFunction pseudocode shown above? ii. What is the space complexity of the IterativeFunction pseudocode shown above? 2. What is the time complexity of the following algorithm (Note that n(n+1) 2,2 n(n+1)(2n+1) 2 and ): Provide both T(n) and order, e(f(n)). int A=0;...

  • Please answer both question. QUESTION 9 Examples of O(1) algorithms are .multiplying two numbers assigning some...

    Please answer both question. QUESTION 9 Examples of O(1) algorithms are .multiplying two numbers assigning some value to a variable displaying some integer on the console all of these QUESTION 10 Examples of O(n^2) algorithms are Adding of two matrices Initializing all elements of a matrix with zero Both of these Neither of these QUESTION 14 Spreadsheets are useful because of their dynamic nature providing the ability to do what-if analysis. True False QUESTION 15 Spreadsheet cells can only contain...

  • Untitled - Notepad File Edit Format View Help Algorithms 1.You have been given a 1le with two columns: a name and an integer (whole number representing how many aquatics training sessions the per...

    Untitled - Notepad File Edit Format View Help Algorithms 1.You have been given a 1le with two columns: a name and an integer (whole number representing how many aquatics training sessions the person has attended in semester 1 between 0 and 24 inclusive. The 1le will look something like: Ada 22 Jordan 10 Anita 15 Xavier 24 are in the 1le, however the 1le will be terminated by It is not known at the outset how many rows EOF (end...

  • 10 pts Question 2 Let A[1.n] and B[1.m] be two arrays, where n 2 mz 1....

    10 pts Question 2 Let A[1.n] and B[1.m] be two arrays, where n 2 mz 1. Use pseudocode to write an algorithm which prints TRUE if the array A contains the sequence B, and FALSE otherwise. The elements from B must appear in order, but they do not have to occur as a contiguous sequence in A. The running time of the algorithm must be O(n). some examples: Here are <5,6,8> then the algorithm prints TRUE - if A =...

  • Please answer in C++, and Please consider ALL parts of the question, especially where it asks the...

    Please answer in C++, and Please consider ALL parts of the question, especially where it asks the user for V. So there should be a "cin >> V" somewhere. The last guy did not answer it correctly so please make sure you do! Thank You!! Question 1 Write the following two functions. The first function accepts as input a two-dimensional array of integers. It returns two results: the sum of the elements of the array and the average The second...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT