Pergunta de entrevista da empresa Goldman Sachs

Find depth of the binary tree? How would you insert an element in sorted array

Resposta da entrevista

Sigiloso

22 de jul. de 2019

Insert element in a sorted array: Make sure the array capacity is at least n+1. If the array capacity is not given, make a new array with length n+1. for(int i = 0; (i >= 0 && arr[i] > key); i--){ arr[i+1] = arr[i]; } arr[i+1] = key;