Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Problem A | Problems
Sorting Algorithms
course content

Conteúdo do Curso

Sorting Algorithms

Sorting Algorithms

1. Simple Algorithms
2. Divide and Conquer Algorithms
3. Problems

Problem A

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 1
toggle bottom row

Problem A

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 1
toggle bottom row

Problem A

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Tarefa

The task is to merge given sorted arrays arr1 and arr2. Do not use ready code from Merge Sort Algorithm.

How to merge: you have two sorted arrays arr1 and arr2, let’s set pointers p1 and p2 at the beginning of each of them (p1=0, p2=0).

Compare current values: if arr1[p1] < arr2[p2], then put arr1[p1] to temp and increase p1 by 1. Else do the same for p2. If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.

Do the following until p1 < len(arr1) or p2 < len(arr2).

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 1
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt