Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help solvinh those 2 questions. please include all the steps and explain your answers. 1. Write Pseudocode for the following a. Write pseudocode

I need help solvinh those 2 questions.
please include all the steps and explain your answers.
image text in transcribed
image text in transcribed
1. Write Pseudocode for the following a. Write pseudocode to determine if there are more odd or even numbers in a list of integers, It should take a list of integer numbers as input and retum either odd" or "even". For example, if given the list [1,2,3,4,5] as input your pseudocode should return "odd" b. Cosine similarity (cos sim) is a commonly used similarity metric that measures how similar two vectors (arrays) of numbers are. The equation for cosine similarity is given by sim(A,B) = 4|-B| where A and B are components of vector A and B respectively. Write pseudocode to calculate cosine similarity of two vectors A and B. it should take two arrays of numbers, A and B, as arguments and return a single value, their cosine similarity. 2. Big-O analysis (Worst Case Time Complexity) a. Find the worst case runtime (big-O notation) for the following pseudo code which returns true if an integer n is prime, false if it is not prime. procedure isPrime(n) if n A[maxIndex] maxindex=; swap(A[i], A[maxIndex]) c. Find the worst case runtime (big-O notation) for BogoSort, pseudocode is given below: procedure BogoSort(array A) while not isInOrder(A): shuffle(A) shuffle() randomly reorders A. isinOrder() returns true if the list is in order, false otherwise. It has the following pseudocode: procedure isInOrder(array A, length(A) = n) for i in 0 to n-1 if A[i]> A[i+1] return false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions