# Questions tagged [arrays]

A sequential random-access data structure whose size can typically not be changed after creation.

495 questions
Filter by
Sorted by
Tagged with
21 views

### Give an O(n^2) algorithm to solve

This is my homework question Given an array A[1..n] of n integers, we want to decide if there exist i and j, where 1 ≤ i , j ≤ n, such that A[i] + A[j] = α for a given value α. Give an O(n^2) ...
18 views

### Why the last elements of the array of heap is itself heap

If we represent a heap using array the 2nd half of the array will be represent the leaf nodes of the heap. But I can not understand for array of length n, all elements in range A[[n/2+1]....n] are ...
14 views

### change an algo to obtain optimal run time

I have an algorithm that does the reverse of partition ...
51 views

### Merging sorted arrays stored as linked lists

I have $k$ sorted arrays stored as linked lists. I need an algorithm to merge them into one single sorted array, also stored as a linked list. How can I do that? My Code: ...
22 views

### Finding a full collision within a large array

I apologize for the vagueness of the title, but this question is quite difficult for me to describe. For that reason, I'm unable to directly convey my problem. In an effort to circumvent this, I've ...
39 views

### prove sub array has a definite form with distinct end point integers

An array has elements from set {0, 1, 2}. A span SP of an array is any interval [start S, end E] such that the sub array must contain all elements from {0,1,2}. For example: in Array A = (0,1,0,1,1,2,...
42 views

### House Robber DP Algorithm (Not three in a row)

This is a similar question to A variant of the house robber problem but instead of the general case, I'm wondering how you would solve the standard house robber problem, but when you cannot rob from ...
89 views

### What could be the most efficient algorithm to find index in an array that matches given conditions?

I have an array A with n elements. I am trying to write an efficient algorithm to find the index of elements that matches condition A[j-1]>=A[j]<=A[j+1]. Example: ...
32 views

### Array Doubling Size Strategies

I would like to discuss resizing strategies for arrays please. If you have an array of $k$ initial size and it gets full, so you would like to choose from one of the following approaches: Approach 1: ...
15 views

### Longest subarray without duplicates within distance K

You are given an array $A$ of of integers, length $N$. What is the longest ("sub") array you can generate from $A$, such that there are no duplicates within distance $K$ of one another. The (...
29 views

### minimum insertions and deletions required to ensure that each value X occurs X times

I would like to brainstorm/get some advice/tips regarding the following question. Given an array,you can either insert elements or you can delete elements from it.Note the insertion/deletion must be ...
47 views

### array empty cell search algorithm

I'm Telecommunication student so I don't have Computer Science background, just in case if my question looks stupid. Here is my scenario: Consider an empty array named ...
32 views