Write a function that tests whether a string is a palindrome. 2. Write a function that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function that tests whether a string is a palindrome. 2. Write a function that merges two sorted lists into a new sorted list. [1,4,6], [2,3,5] → [1,2,3,4,5,6]. You can do this quicker than concatenating them followed by a sort. 3. Write a function that rotates a list by k elements. For example [1,2,3,4,5,6] rotated by two becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? 4. Write a function that computes the list of the first 100 Fibonacci numbers. The first two Fibonacci numbers are 1 and 1. The n+1-st Fibonacci number can be computed by adding the n-th and the n-1-th Fibonacci number. The first few are therefore 1, 1, 1+1=2, 1+2=3, 2+3=5, 3+5=8. 5. Write a function that takes a number and returns a list of its digits. So for 2342 it should return [2,3,4,2]. 6. Write a function that takes a list of numbers, a starting base b1 and a target base b2 and interprets the list as a number in base b1 and converts it into a number in base b2 (in the form of a list-of-digits). So for example [2,1,0] in base 3 gets converted to base 10 as [2,1]. 7. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding 'ay'. "The quick brown fox" becomes "Hetay uickqay rownbay oxfay". 8. Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,...,9 (in this order) such that the result is 100. For example 1+ 2+ 3-4+5 + 6+ 78 + 9 = 100. Write a function that tests whether a string is a palindrome. 2. Write a function that merges two sorted lists into a new sorted list. [1,4,6], [2,3,5] → [1,2,3,4,5,6]. You can do this quicker than concatenating them followed by a sort. 3. Write a function that rotates a list by k elements. For example [1,2,3,4,5,6] rotated by two becomes [3,4,5,6,1,2]. Try solving this without creating a copy of the list. How many swap or move operations do you need? 4. Write a function that computes the list of the first 100 Fibonacci numbers. The first two Fibonacci numbers are 1 and 1. The n+1-st Fibonacci number can be computed by adding the n-th and the n-1-th Fibonacci number. The first few are therefore 1, 1, 1+1=2, 1+2=3, 2+3=5, 3+5=8. 5. Write a function that takes a number and returns a list of its digits. So for 2342 it should return [2,3,4,2]. 6. Write a function that takes a list of numbers, a starting base b1 and a target base b2 and interprets the list as a number in base b1 and converts it into a number in base b2 (in the form of a list-of-digits). So for example [2,1,0] in base 3 gets converted to base 10 as [2,1]. 7. Write function that translates a text to Pig Latin and back. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding 'ay'. "The quick brown fox" becomes "Hetay uickqay rownbay oxfay". 8. Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,...,9 (in this order) such that the result is 100. For example 1+ 2+ 3-4+5 + 6+ 78 + 9 = 100.
Expert Answer:
Answer rating: 100% (QA)
1 Palindrome Check java public static boolean isPalindromeString str str strreplaceAllazAZ09 toLowerCase int left 0 int right strlength 1 while left r... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
The wave function associated with standing waves established in a 5.00 m long light-weight rope is y = 0.00300 sin(x)cos(110t) where x and y are in meters and t is in seconds. (a) How many...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
What pricing system is used to price the water you use at your college or university? Does this pricing system affect your behavior about water use (length of showers, etc.)? How? Could you recommend...
-
A parabolic slot has been cut in plate AD, and the plate has been placed so that the slot fits two fixed, frictionless pins B and C. The equation of the slot is 2/100y = x, where x and y are...
-
5. a) In a marathon, the median finishing time was 3:35:04 (three hours, 35 minutes, and four seconds). You finished in 3:34:10. Provide the interpretation and meaning of the median time, and discuss...
-
How might the attributes of a highly motivated employee change for different job descriptions?
-
Loco Leasing and Manufacturing Company uses leases as a means of financing sales of its equipment. Loco leased a machine to Potomac Construction for $15,000 per year, payable in advance, for a...
-
A clear plastic paperweight with an unknown index of refraction rests on your desk as shown in the figure. A ray of light enters the top of the paper weight with a 65.0 angle of incidence a undergoes...
-
At 31 December 20X8, Northern Resources Ltd. reports the following on its statement of financial position: Bonds payable, 5%, interest payable semi-annually on 30 June and 30 December Discount on...
-
Below is a frequency distribution for our RCCC sample of men's heights. Frequency Class Class Midpoint (inches) 56-59 1 0 12 C. 60-63 64-67 68-71 72-75 76-79 12 11 2 a. Fill in the midpoint of each...
-
What makes the U.S. dollar exchange rate fluctuate?
-
Shaffer ordered a glass of ros wine at the Victoria Station Restaurant. As he took his first sip of wine, the glass broke in his hand, causing permanent injuries. Shaffer brought suit against the...
-
The figure shows the demand for money curve. If the quantity of money decreases from $4 trillion to $3.9 trillion, explain how the price of a bond will change. Interest rate (percent per year) 8 6 4...
-
What is required by the Consumer Leasing Act?
-
Herman Googe agreed to buy an automobile from Irene Schleimer. Later, Googe changed his mind and refused to buy the car. Schleimer, without making tender of delivery, brought suit against Googe for...
-
a)What is the air speed v1 at point 1? b)What is the air speed v2 at point 2? c)What is the volume flow rate? Figure included above Air at 20 C flows through the tube shown in (Figure 1). Assume that...
-
Determine whether the lines are parallel, perpendicular, or neither. 2x + 3y = -12, 2y - 3x = 8
-
Write a server for a client. The client sends the weight and height for a person to the server (see Figure 31.18a). The server computes BMI (Body Mass Index) and sends back to the client a string...
-
Rewrite Programming Exercise 15.24 so that the ball?s opacity is changed as it swings. Write a program that animates a palindrome swing as shown in Figure. Press/release the mouse to pause/resume the...
-
Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays a line that connects the pair of nearest points, as shown in Figure 22.4. |...
-
You shoot a beam of electrons through a double slit to make an interference pattern. After noting the properties of the pattern, you then double the speed of the electrons. What effect would this...
-
How many photons does a \(5.0 \mathrm{~mW}\) helium-neon laser \((\lambda=633 \mathrm{~nm})\) emit in 1 second? A. \(1.2 \times 10^{19}\) B. \(4.0 \times 10^{18}\) C. \(8.0 \times 10^{16}\) D. \(1.6...
-
Light consisting of \(2.7 \mathrm{eV}\) photons is incident on a piece of potassium, which has a work function of \(2.3 \mathrm{eV}\). What is the maximum kinetic energy of the ejected electrons? A....
Study smarter with the SolutionInn App