Pregunta de entrevista de Goldman Sachs

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

Respuesta de la entrevista

Anónimo

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;