1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OLga [1]
3 years ago
12

Extend the class linkedListType by adding the following operations: Write a function that returns the info of the kth element of

the linked list. If no such element exists, terminate the program. Write a function that deletes the kth element of the linked list. If no such element exists, terminate the program.
Computers and Technology
1 answer:
WINSTONCH [101]3 years ago
6 0

Answer:

Explanation:

The following code is written in Java. Both functions traverse the linkedlist, until it reaches the desired index and either returns that value or deletes it. If no value is found the function terminates.

public int GetNth(int index)

       {

       Node current = head;

       int count = 0;

       while (current != null)

       {

       if (count == index)

       return current.data;

       count++;

       current = current.next;

       }

       assert (false);

       return 0;

       }

public int removeNth(int index)

       {

       Node current = head;

       int count = 0;

       while (current != null)

       {

       if (count == index)

       return current.remove;

       count++;

       current = current.next;

       }

       assert (false);

       return 0;

       }

You might be interested in
The other term for template document is _______.
evablogger [386]

hi

I think so MAIN DOCUMENT

I hope it is correct

6 0
2 years ago
Read 2 more answers
Given the following sequence of integers: 12, 19, 10, 4, 23, 7, 45, 8, 15 Build a heap by inserting the above set, one integer a
Gre4nikov [31]

Answer:

Check the explanation

Explanation:

Kindly check the attached images below to see the step by step explanation to the question above.

7 0
3 years ago
How to write a program that prompts the user to input two POSITIVE numbers — a dividend (numerator) and a divisor (denominator).
fomenos

Answer:

num1 = int(input("Numerator: "))

num2 = int(input("Denominator: "))

if num1 < 1 or num2<1:

     print("Input must be greater than 1")

else:

     print("Quotient: "+str(num1//num2))

     print("Remainder: "+str(num1%num2))

Explanation

The next two lines prompts the user for two numbers

<em>num1 = int(input("Numerator: "))</em>

<em>num2 = int(input("Denominator: "))</em>

The following if statement checks if one or both of the inputs is not positive

<em>if num1 < 1 or num2<1:</em>

<em>      print("Input must be greater than 1")-> If yes, the print statement is executed</em>

If otherwise, the quotient and remainder is printed

<em>else:</em>

<em>      print("Quotient: "+str(num1//num2))</em>

<em>      print("Remainder: "+str(num1%num2))</em>

<em />

3 0
3 years ago
Computer are most wonderful creation of 21st century how ?​
son4ous [18]

Answer:

It can do all the functions at a speedy rate and also helps us to search and progress in our homes and businesses. A computer can therefore be called a calculator with a twist for not only does it perform fast calculations, but it also has other special characteristics.

Explanation:

hope it helps you

6 0
2 years ago
Python is an example of a low level programming language true or false?​
alekssr [168]
False- python is an example of a high level language. Other high levels are c++, PHP, and Java
6 0
3 years ago
Other questions:
  • Given a floating point variable fraction, write a statement that displays the value of fraction on the screen. Do not display an
    13·1 answer
  • What Is the output of the following: =OR (5 &lt;7, 16*Rand ()&gt;23,FALSE)
    5·1 answer
  • Checking the ___________ will reduce the possibility of having to rebuild or replace the engine.
    9·2 answers
  • Before using large downloaded files that are in a compressed format, it is necessary to_____ them. A) Copy B) Extract C) Open D)
    9·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • Presentation graphics programs contain an assortment of tools and operations for creating and editing slides, including preforma
    8·2 answers
  • Plz help fast! will mark brainliest!<br><br>List three ways that music is used in modern society.
    6·1 answer
  • Setting up a desktop computer for anAutoCADspecialist who needs a minimum of 125 GBram which operating system would be the best
    5·1 answer
  • What are the different Stape of data processing cycle?​
    8·1 answer
  • What is a simple definition for electricity?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!