C programming sorting an array of structs based on 4 strings -
C programming sorting an array of structs based on 4 strings -
edit: forgot mention begins circular linked list! need sort array of contact structs, defined below, in next order:
last name first name email phone number
how go this, in efficient way? which sorting method best fit, in terms of big o order?here struct definition:
struct contact { char firstname[256], lastname[256], email[256], phonenumber[256]; struct contact *pprev; struct contact *pnext; };
it looks info organized in list (due pprev , pnext). qsort() cannot used on lists.
for lists mergesort way go: long list contains more 1 element, split 2 lists, sort each of them, merge 2 sorted lists one: since both lists sorted heads have compared. compare heads of 2 lists, remove smaller 1 , append sorted list.
complexity o(n*log n)
c arrays string sorting struct
Comments
Post a Comment