-
Characteristics of an Algorithm
List out the characteristics of an algorithm
-
Array Values Algorithms
How many values can be held by an array with dimensions A(0:n), B(-1:n,1:m), C(-n:0,2)?
-
-
Linked List Kth largest Element
How to find the kth largest element in a linked list? Can you do this without using extra memory and also without modifying (sorting) the list?
-
Calculate Money Paid to Each Worker
A carpenter is paid a contract fee of $2000.00 for 3 days work. He hires 3 workers who work for the 3 days at $75.00 a day: calculate and print the amount of money paid to each worker; the total paid to all workers and the amount the carpenter is left with.
-
Pseudocodes and flowcharts
When twice a certain number is subtracted from five times itself, the result equals 60. Find the number by using the try and error method. Use both pseudocode and flowchart.
-
Calculate Primary and Secondary Diagonal
Write an algorithm that calculates all the elements of rows and columns of a square matrix and calculate the total of primary and secondary diagonal.
-
-
Read the Day and the Weather
A club plays cricket only on Sundays and only if it is not raining. Read the day and the weather and "Game on" if the weather is good and the day is Sunday, or "Play Suspended" if it is not Sunday and it is raining.
-
Calculate Number of Oil Pipes Required
Pipes are laid by an oil company. If the company has to laid down 3 km of pipe and each pipe is 25 metres long, calculate and print the number of pipes needed to cover the distance.
-
Topological Sort Algorithm
Are there any topological sorting algorithms that, given a binary matrix A, (1) find the number of distinct rows of A and (2) for any row find the set of all equal rows? Can you give me some references of where I can find them?
-
Linked List
How will you reverse a singly linked list?
-
Game of Jack Straws
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. In the question here, we are concerned with the following, related problem: First n straws are dumped on the table. Next, for every pair of straws, we want to determine if the straws are connected by a path of touching straws. In other...
-
-
Distinct palindromic sub strings
I want to calculate number of DISTINCT palindromic substrings in a string.How to do it?
Like if aba is string the their are 3 distinct palindromic subsrings:{a,aba,b}
length of string could be 10^5 range.So i dont think O(n^2) solution will work.I want a algorithm to do this in less than O(n^2). -
How can you traverse a matrix of m lines and n columns in a zig-zag way ?
Example : 1)m = 3,n = 2 a11 a12 a21 a22a31 a32Output : a11 a21 a12 a31 a22 a322) m = 3, n = 4a11 a12 a13 a14a21 a22 a23 a24a31 a32 a33 a34Output : a11 a21 a12 a31 a22 a13 a32 a23 a14 a33 a24 a34
-
Algorithm help
Create the flowchart and algorithm for a module that will prompt the user to enter the amount of cash they have in their pocket. The program should output “Not Enough” ($0 - $0.64), “Vending Machine” ($0.65 - $1.99), “Fast Food” ($2.00 - $4.99), “Cafeteria” ($5.00 - $14.99) or “Steak House” ($15 and up) depending on what the user can afford for lunch.
-
Python - How to Write a function
How to Write a function kinda_format ( ) that take three arguments (each of which positive int ) - a,b,c- and tests whether the equality a^n +b^n=c^n holds for each n{2,3,...,10}. The function should return false if the equality does not hold for any value of n in the given range, and if there is a value of n for which the equality holds, the lowest such value (as in int)
-
Finding a 'circle' in a linked list
You have n numbrer Node objects - could be 1,000,000 for all you know. Each Node has a getNext() method that returns the next Node (a linked list).But the chain of n number of Node objects linked together by the getNext() method, somewhere in the chain, points back to a Node earlier in the chain so if you keep calling getNext() to walk the chain you will never get to the last Node - it will loop forever.What...
-
Intersection of two convex polygons
Suppose that you are given m convex polygons P1; P2; : : : ; Pm in the plane. Let ni denote the
number of vertices on Pi and n =
Pm
i=1 ni. The vertices of each polygon is listed in counter-
clockwise order, starting at the leftmost vertex of Pi (that is, the one with the smallest x-
coordinate). Two polygons Pi and Pj are said to intersect if they contain any point in...
Algorithm Questions
Ans