Coding Questions: Array Manipulations
9 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What will be the main result of the program that removes prime numbers from an array?

  • It will output the original array unchanged.
  • It will print the non-prime numbers in the array. (correct)
  • It will output the smallest prime number remaining.
  • It will print an array containing only even numbers.
  • Which output is generated by reversing the array elements [10, 20, 30, 40, 50]?

  • 50, 40, 30, 20, 10 (correct)
  • 20, 30, 40, 50, 10
  • 10, 20, 30, 40, 50
  • 30, 20, 10, 50, 40
  • What should be included in the output when finding the smallest and largest elements in an input array?

  • Both the smallest and largest elements printed on the same line.
  • Only the smallest element.
  • Only the largest element.
  • The smallest element on the first line and the largest element on the second line. (correct)
  • In the context of sorting an array, what would be the output of sorting the array [50, 10, 20, 40, 30]?

    <p>10, 20, 30, 40, 50</p> Signup and view all the answers

    What does the input format specify for taking to create an array for processing?

    <p>An integer n must be provided as the first input followed by n elements.</p> Signup and view all the answers

    Given the input array [100, 200, 31, 13, 97, 10, 20, 11], which numbers will remain after removing all prime numbers?

    <p>100, 200, 10, 20</p> Signup and view all the answers

    What is the expected output if the input is the array [7, 11, 15, 16, 19] when removing prime numbers?

    <p>15, 16</p> Signup and view all the answers

    What is the main purpose of the 'New Paradise' program described?

    <p>To identify locations with the maximum number of travel routes.</p> Signup and view all the answers

    Which of the following operations is performed to swap elements in an array?

    <p>Swapping the first with the last, second with second last, etc.</p> Signup and view all the answers

    Study Notes

    Coding Questions

    • Several coding problems are described, each with input, output, and formatting requirements.
    • Input formats involve taking integer values (array size, array elements) from the user.
    • Output formats vary, including:
      • Array elements after swapping/reversing
      • Smallest and largest elements in an array
      • Array elements after removing prime numbers
      • Sorted array elements in ascending order
    • Constraints usually limit the size of the input array (e.g., n >= 1 && n <= 10000) and the values within the array.

    Problem 26: Remove Prime Numbers

    • Input: An array of integers.
    • Output: The array with all prime numbers removed.
    • Example Input: 100, 200, 31, 13, 97, 10, 20, 11
    • Example Output: 100, 200, 10, 20

    Problem 27: Array Sorting

    • Input: An unsorted array of integers.
    • Output: The sorted array in ascending order.
    • Example Input: 50, 10, 20, 40, 30
    • Example Output: 10, 20, 30, 40, 50

    Problem 25: Swap Array 1

    • Input: An array of integers.
    • Output: The array with elements swapped in reverse order.
    • Example Input / Output:
      • Input 1234 -> Output 4321
    • This describes elements of an array and reversing them.

    Problem 30: New Paradise

    • Input: A single integer representing the number of locations. Integer values for the number of routes through each location are given as input.
    • Output: A single integer representing the number of locations with the maximum number of routes.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz presents a series of coding problems focused on array manipulations such as removing prime numbers and sorting arrays. Each problem provides input requirements along with expected outputs, ensuring a comprehensive understanding of array handling. Challenge your coding skills with these varied tasks!

    More Like This

    Use Quizgecko on...
    Browser
    Browser