You are designing an algorithm that ranks website pages by relevance according to the number of times they are viewed by users.

Python

LANGUAGE:  PYTHON CHALLENGE: You are designing an algorithm that ranks website pages by relevance according to the number of times they are viewed by users. Which data structure would be the most useful and efficient for you to use? A hash table because data would be efficiently searched and retrieved A stack because the website…

Read More

Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k ‘s value is smaller than m ‘s.

Python

LANGUAGE:  PYTHON CHALLENGE: Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k ‘s value is smaller than m ‘s. Write the code necessary to compute the number of perfect squares between k and m. (A perfect square is an integer like 9 ,…

Read More

Assign the sum you compute to a variable q For example, if h is 19, you would assign 4 to q because there are perfect squares (starting with 1 ) that are less than h are: 1 , 4 , 9 , 16.

Python

LANGUAGE:  PYTHON CHALLENGE: Assume there is a variable, h already associated with a positive integer value. Write the code necessary to count the number of perfect squares whose value is less than h, starting with 1. (A perfect square is an integer like 9 , 16 , 25 , 36 that is equal to the…

Read More

Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters.

java

LANGUAGE: JAVA CHALLENGE: Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int. Write an efficient static method, getWidgetMatch, that has two parameters. The first parameter is a reference to a Widget object. The second parameter is a potentially…

Read More

Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created.

C++

LANGUAGE: C++ CHALLENGE: Design a class called Date that has integer data members to store month, day, and year. The class should have a three-parameter (day-of-month, month, year) default constructor that allows the date to be set at the time a new Date object is created. If the user creates a Date object without passing any…

Read More

Write a full class definition for a class named Averager, and containing the following members: An data member named sum of type integer. An data member named count of type integer.

C++

LANGUAGE: C++ CHALLENGE: Write a full class definition for a class named Averager, and containing the following members: An data member named sum of type integer. An data member named count of type integer. A constructor with no parameters. The constructor initializes the data members sum and the data member count to 0. A function named…

Read More

Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise.

java

LANGUAGE: Java CHALLENGE: Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared. Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise. Do not use an if statement in this…

Read More

Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 thorugh 64, and adds 1 to the variable seniors if age is 65 or older.

Visual Basic

LANGUAGE: Visual Basic CHALLENGE:  Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 thorugh 64, and adds 1 to the variable seniors if age is 65 or older.

Read More