I was discussing with some friends a piece of code, and we discussed about using memset function in C, which is the order in Big-O notation for this function if we initialize an array of size N?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On a system where you have direct access to the page tables and they’re stored in a hierarchical way,
memsetcould be implemented inO(log n)by replacing the whole virtual address mapping with copy-on-write references to a single page filled with the given byte value. Note however that if you’re going to do any future modifications to the object, the normalO(n)cost ofmemsetwould just be deferred to the page fault to instantiate separate copies of the pages when they’re modified.