Pregunta de entrevista de Cognizant

Q: How do you optimize a SQL query to improve performance? A: I analyze the query execution plan, use appropriate indexing, avoid SELECT *, and minimize joins or subqueries where possible. Q: Explain the difference between REST and SOAP APIs. A: REST is lightweight, uses JSON, and is stateless, whereas SOAP is protocol-based, uses XML, and has built-in error handling. REST is generally preferred for web services. Q: How would you implement a binary search algorithm in Python? A: I would use a recursive or iterative approach, dividing the sorted array into halves and comparing the target with the middle element to determine the search direction. Q: What are the differences between MongoDB and MySQL? A: MongoDB is NoSQL, schema-less, and stores data as JSON-like documents, while MySQL is a relational database with a fixed schema and uses tables with rows and columns. Q: How do you handle version control in a collaborative project? A: I use Git for version control, create feature branches for development, commit changes with clear messages, and merge using pull requests after code reviews. Q: Can you explain the MVC architecture? A: MVC stands for Model-View-Controller. The Model manages data and business logic, the View handles the UI, and the Controller connects the two, processing user inputs and updating the model or view accordingly.