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
A laptop gets replaced if there's a hardware issue. Which stage of the hardware lifecycle does this scenario belong to?
Ilya [14]

Answer: Maintenance. This is the stage where software is updated and hardware issues are fixed if and when they occur. Retirement. In this final stage, hardware becomes unusable or no longer needed and it needs to be properly removed from the fleet

Explanation:

3 0
3 years ago
Write two versions of a program that reads a sequence of positive integers from the user, calculates their geometric mean, and p
givi [52]

Answer:

1)

n = int(input("Please enter the length of the sequence: "))

print("Please enter your sequence")

product = 1

for i in range(n):

   val = int(input())

   product *= val

print("The geometric mean is: %.4f"%pow(product,1/n))

2)

print("Please enter a non-empty sequence of positive integers, each one is in a separate line. End your sequence by typing done:")

product = 1

val = input()

n = 0

while(val!="done"):

   product *= int(val)

   n += 1

   val = input()

print("The geometric mean is: %.4f"%pow(product,1/n))

Explanation:

4 0
3 years ago
List the different generation of computers with its main component​
Dennis_Churaev [7]

Answer:

1940 – 1956:  First Generation

1956 – 1963: Second Generation

1964 – 1971: Third Generation

1972 – 2010: Fourth Generation

2010-  : (Present )Fifth Generation

Explanation:

  1. First Generation Computers (1940-1956):In this Generation the main component of computers were Vacuum Tubes.
  2. Second Generation Computers (1956-1963):In this generation the main component of computers were Transistors.
  3. Third Generation Computers (1964-1971):In this generation the main component of computers were Integrated Circuits.
  4. Fourth Generation Computers (1972-2010):In this generation the main component of computers were Microprocessor
  5. Fifth Generation (2010-Present):In this generation the main component of computers is Artificial Intelligence
4 0
3 years ago
V.kofiryfh givnyovb (to slove you must go back 3 letters)
Elena L [17]
Im goin to be honest with you i dont understand this question at all can you xplain it alittle more plz cuz if i go back three letters it is o
7 0
3 years ago
A digital footprint is .
BlackZzzverrR [31]

Your digital footprint is the trail of 'electronic breadcrumbs' you leave behind when you use the internet. It can include the websites you visit, the photos you upload and your interactions with other people on social networks.

3 0
3 years ago
Other questions:
  • Drivers must always yield to emergency vehicles traveling
    9·1 answer
  • 1. What does a transistor do?
    6·1 answer
  • Skinner designed a soundproof apparatus, often equipped with a lever or bar, with which he conducted his experiments in operant
    9·1 answer
  • Artie believes that all Asian people are more intelligent than other people. Artie is engaging in?
    12·2 answers
  • Assuming a user enters 25 as input, what is the output of the following code snippet? int i = 0; Scanner in = new Scanner(System
    11·1 answer
  • Why do you think that backlighting is used in so much of Sheldon’s photography?
    7·2 answers
  • HELP PLEASE ASAP!!! Does anyone know how to fix a broken iPhone which when I connect it to the charger it comes up with the Appl
    5·1 answer
  • What is the term for movement in particular direction
    15·2 answers
  • The introduction of an academic paper must include a:
    12·2 answers
  • Please help with my Python code - Functions
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!