Master Computers and Technology with Fun Quizzes & Brain Teasers!
Implement the following logic in C++, Use appropriate data types. Data types are represented as either numeric (num) or string.startstring namestring addressnum item //use intnum quantitynum price //use double as data typenum SIZE = 6num VALID_ITEM [SIZE] = 106, 108, 307, 405, 457, 688 //use int as data typenum VALID_ITEM_PRICE [SIZE] = 0.59, 0.99, 4.50, 15.99, 17.50, 39.00 //use double as data typenum ibool foundIt = falsestring MSG_YES = "Item available"string MSG_NO = "Item not found" get name, address, item, quantityi = 0while i < SIZE if item == VALID_ITEM [i] then foundIt = true price = VALID_ITEM_PRICE [i] endif i = i + 1endwhile if foundIt == true then print MSG_YES print quantity, " at " , price, " each" print "Total ", quantity * price elseprint MSG_NOendifstop
I need to know how to input this into python on zybooks. I've been stuck on this for days and I keep running into "invalid syntax" or "unknown word red" Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part. Ex: If the input is 130 50 130, the output is: 80 0 80 Find the smallest value, and then subtract it from all three values, thus removing the gray.
The algorithm S(A, n, i) selects all the j-th smallest elements (with j i) from an array A of n elements, by using linearselect to select each of the j-th smallest elements (with j i). Clearly, one could also implement S alternatively as T(A, n, i), which first sort A (on average-case and on worstcase, the sorting takes time O(n log n) using mergesort) and then select the first i elements. Please compare the average-case complexities of the two algorithms; i.e., For the average-case complexities, under what conditions (on the choices for i), S is better than T or vice versa