0% found this document useful (0 votes)
18 views

Algorithms Review - Arrays

This document provides a review of programming basics regarding arrays and algorithms. It lists 8 challenges involving manipulating arrays of integers or characters. For each challenge, the document describes the input, expected output, and sometimes provides example test cases. It recommends starting with an iterative solution before implementing a recursive one for each challenge. The challenges include rotating, reversing, finding subsequences that sum to zero, returning all pairs, checking for palindromes, comparing neighbors, finding a sequence of characters, and calculating minimum, maximum and average.

Uploaded by

Carlos Junior
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Algorithms Review - Arrays

This document provides a review of programming basics regarding arrays and algorithms. It lists 8 challenges involving manipulating arrays of integers or characters. For each challenge, the document describes the input, expected output, and sometimes provides example test cases. It recommends starting with an iterative solution before implementing a recursive one for each challenge. The challenges include rotating, reversing, finding subsequences that sum to zero, returning all pairs, checking for palindromes, comparing neighbors, finding a sequence of characters, and calculating minimum, maximum and average.

Uploaded by

Carlos Junior
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Basics - Algorithms Review

Arrays Review
1. #PB1501
Arrays

Before you start

All exercises should be solved and submitted, as instructed in class.

You should clearly identify all used variables with the proper name conventions, data types
and default/initial values.

Whenever possible, all algorithms should be defined in a reusable way. Don't forget to set
the required outputs.
In some cases, we recommend that you do not use the OS built-in
client actions while implementing an algorithm.
Build a test table for each exercise and
include those tables in the submitted homework.

Create a recursive algorithm for each of the following challenges. We recommend that you
start by implementing an iterative version of the algorithm first, and then do the recursive
version.

Create algorithms to solve the following challenges.

1. Rotate to the left the elements of a given array of integers and return the new array.

Ex: inputting [8, 2, 6, 1, 3, 4] outputs [2, 6, 1, 3, 4, 8]

2. (optional) Reverse a given array of integers.

Ex: inputting [8, 2, 6, 1, 3, 4] outputs [4, 3, 1, 6, 2, 8]

3. (optional) Given an array of integers, if it has a sequential subarray of values that sum
zero, return those subarrays.

Ex: inputting [10, -10, 0, 5, 3, -5, 3]

outputs [ [10, -10], [10, -10, 0], [10, -10, 0, 5, 3, -5, 3], [0 ], [0, 5, 3, -5, 3],

4. (optional) Given an array of integers, return all the possible pairs.

Ex: inputting [3 1 6] returns [ [3, 1], [3, 6], [1, 6] ] as an array of pairs.

Or, alternatively, inputting [3 1 6] returns (3, 1), (3, 6), (1, 6) as a text.

5. Find if an array is a palindrome or not. If you do this with OutSystems, you can use the
built-in functions Substr() and Length().

The information contained in these documents is privileged and only for the use of the intended recipient and may not be
1
used, reproduced, published, or redistributed without the prior written consent of ITUp.
Ex: inputting [ABBA] outputs true, inputting [AKA] outputs true inputting [APART] inpu

6. (optional) Given an array of integers, print/display the gt(>), lt(<), or eq(=) signs between
them if they are bigger, smaller, or equal to their respective neighbor to the right.

Ex: inputting [8, 9, 6, 7, 3, 4] outputs (8 < 9 > 6 < 7 > 3 < 4)

7. (optional) Given an array of letters (characters), find the sequence with the letters I, T, U, P
in that order. Then, print the positions of those chars.

If you do this with OutSystems, and since there's no character data type in Outsystems,
you can create a structure with one attribute of data type text and with the length
property set to 1, name the structure 'Char', and then create a variable with the data type
set to Char list.
8. Given an array of numbers, print/display the minimum, maximum, and average of those
numbers.

The information contained in these documents is privileged and only for the use of the intended recipient and may not be
2
used, reproduced, published, or redistributed without the prior written consent of ITUp.

You might also like